PDA

View Full Version : GLU_TESS_VERTEX question



ahuarte
01-09-2003, 10:13 PM
Hello I want define my own GLU_TESS_VERTEX function. I declare "myVertex3dv" function in order to send the vertice array in a step.
I want avoid use ...
for (i = 0; i < iCount; i++) gluTessVertex(tess, (GLdouble *)(pPoints+i), (GLdouble *)(pPoints+i));

I want use ...
glVertexPointer(3, GL_DOUBLE, 0, (const GLdouble *)&(pPoints+0)->x);

Then I setup the tesselator object, but my "myVertex3dv" function is not called.
How I do??

Thank you very much.


GLUtesselator * tess = gluNewTess();
gluTessCallback(tess, GLU_TESS_BEGIN, (tptrf)glBegin);
gluTessCallback(tess, GLU_TESS_VERTEX, (tptrf)myVertex3dv);
gluTessCallback(tess, GLU_TESS_EDGE_FLAG, (tptrf)glEdgeFlag);
gluTessCallback(tess, GLU_TESS_END, (tptrf)glEnd);

gluTessBeginPolygon(tess, NULL);
gluTessBeginContour(tess);
//->for (i = 0; i < pElement->Geom.NumPoints; i++) gluTessVertex(tess, (GLdouble *)(pElement->Geom.pPoints+i), (GLdouble *)(pElement->Geom.pPoints+i));
gluTessVertex(tess, (GLdouble *)(pElement->Geom.pPoints), pElement->Geom.pPoints);
gluTessEndContour(tess);
gluTessEndPolygon(tess);

glFlush();
gluDeleteTess(tess);

void APIENTRY CALLBACK myVertex3dv(_3DPoint * pPoints)
{
glVertexPointer(3, GL_DOUBLE, 0, (const GLdouble *)&(pPoints+0)->x);
}

JustHanging
01-10-2003, 03:45 AM
Hello.

You have got it wrong, it can't be done that way. As far as I know, the only way to send vertice to the tesselator is to loop through them all and call gluTessVertex for each.

The callback function is the function the tesselator calls to draw primitives, and it should either call glVertex or store the data somewhere for future use. glVertexPointer won't do much good here, since it doesn't even draw anything. It tells gl where the vertex data is, the actual drawing is done with glDrawElements or so. Any case, it has nothing to do with tesselators.

If the callback isn't called at all, it's because you only send one vertex to the tesselator, which isn't enough to define any polygon.

So just send the vertice the way you used to. I'm quite sure it's not your bottleneck.

-Ilkka

ahuarte
01-10-2003, 04:27 AM
Thanks your reply.
I see that I need call "gluTessVerter" for every vertex.

In order to avoid this because I have large polygons whith about 5000 vertices, there is the source code of a lovely "tesselator" ???

Thanks.
ahuarte



Originally posted by JustHanging:
Hello.

You have got it wrong, it can't be done that way. As far as I know, the only way to send vertice to the tesselator is to loop through them all and call gluTessVertex for each.

The callback function is the function the tesselator calls to draw primitives, and it should either call glVertex or store the data somewhere for future use. glVertexPointer won't do much good here, since it doesn't even draw anything. It tells gl where the vertex data is, the actual drawing is done with glDrawElements or so. Any case, it has nothing to do with tesselators.

If the callback isn't called at all, it's because you only send one vertex to the tesselator, which isn't enough to define any polygon.

So just send the vertice the way you used to. I'm quite sure it's not your bottleneck.

-Ilkka