PDA

View Full Version : How to get GLlist content after tesselation?



Victor M
08-30-2007, 05:23 AM
for example i have an array of coordinates - contour of country border. After tesselation i have all information in GlList. How can i get post tesselation data?

if i use something like this

...
var fb: TFBBuffer;
...
glFeedbackBuffer(SizeOf (fb), GL_3D_COLOR, @fb);

glRenderMode(GL_RENDER);
glCallList(1);
glRenderMode(GL_FEEDBACK);
glCallList(2);
n := glRenderMode(GL_RENDER);
If n > 0 then PrintBuffer(fb, n);


well i have data... but this is not coordinates from my array. this is screen coordinates of polygon. it is not suitable for me besause if country is very large, like china, screen data is wrong - there are no detailed coastlines after changing scale. several points from my array substituted by on screen point. Results for small countries like luximbourg very well... but for large countires it looks nice only without chinging scale.

p.s. sorry for english

sharp_pixel
08-31-2007, 12:37 AM
I don't think there is a way to extract things from a display list.
The tesselation data must be output by the tesselation algorithm.
If you used a gluTesselator, you can store that data in the callback functions.

Victor M
08-31-2007, 10:00 AM
ok for example i try to extract data from tesselator like this:

procedure inittess;
var
tobj : GLUtesselator;
l,k : integer;
begin
tobj := gluNewTess;
gluTessCallback(tobj, GLU_TESS_BEGIN, @glBegin);
gluTessCallback(tobj, GLU_TESS_VERTEX, @vertexCallback);
gluTessCallback(tobj, GLU_TESS_END, @glEnd);
gluTessCallback(tobj, GLU_TESS_ERROR, @errorCallback);
gluTessCallback(tobj, GLU_TESS_COMBINE, @combineCallback);
gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE);

glNewList(listnum, GL_COMPILE_AND_EXECUTE);
gluTessBeginPolygon (tobj, nil);
gluTessBeginContour(tobj);
For l:=1 to ipol_tmp do begin
For k:=1 to pins6[l] do begin
Application.ProcessMessages;
gluTessVertex(tobj, @points6m_seg[l,k], @points6m_seg[l,k]);
end;
end;
gluTessEndContour(tobj);
gluTessEndPolygon(tobj);
glEndList;
end;
gluDeleteTess(tobj);
end;

procedure vertexCallback (vertex : pointer);stdcall;
var
vertex2 : ^GLDouble;
x,y,z : GLFloat;
begin
vertex2 := vertex;
x:=vertex2^;
inc(vertex2);
y:=vertex2^;
inc(vertex2);
z:=vertex2^;
//x,y,z - now contain vertex ... storing etc..
glVertex3dv(vertex);
end;

Now i have an array of data which looks very nice as it is original coordinates.
But the consequences of coordinates compared with feedback render mode is different.
As a result when i try to output data as triangles or any other possible mode - i fail.
polygon filled with errors. I compare both arrays point by point and found that in spite of
coordinates very close to each other they at the same time different.
feedback render array have more points - this array look like tessellate algorithm make some
internal arrangements to divide data into the triangles. all my attempt to found such algorithm failed.
i think it a serious secret of opengl team.... or may be i don no some thing pls advise.!