PDA

View Full Version : Can someone tell me what this function does?

meshwal
05-26-2016, 11:19 AM
I want to know what this function does.

GLdouble thickness, GLuint side, GLuint edge, GLuint whole)
{
static GLUtriangulatorObj *tobj = NULL;
GLdouble vertex[3], dx, dy, len;
int i;
int count = dataSize / (int) (2 * sizeof(GLfloat));

if (tobj == NULL) {
tobj = gluNewTess();
gluTessCallback(tobj, GLU_BEGIN, (void (__stdcall *)(void)) glBegin);
gluTessCallback(tobj, GLU_VERTEX, (void (__stdcall *) (void)) glVertex2fv);
gluTessCallback(tobj, GLU_END, glEnd);
}
glNewList(side, GL_COMPILE);
gluBeginPolygon(tobj);
for (i = 0; i < count; i++) {
vertex[0] = data[i][0];
vertex[1] = data[i][1];
vertex[2] = 0;
gluTessVertex(tobj, vertex, data[i]);
}
gluEndPolygon(tobj);
glEndList();
glNewList(edge, GL_COMPILE);
for (i = 0; i <= count; i++) {
glVertex3f(data[i % count][0], data[i % count][1], 0.0);
glVertex3f(data[i % count][0], data[i % count][1], thickness);
dx = data[(i + 1) % count][1] - data[i % count][1];
dy = data[i % count][0] - data[(i + 1) % count][0];
len = sqrt(dx * dx + dy * dy);
glNormal3f(dx / len, dy / len, 0.0);
}
glEnd();
glEndList();
glNewList(whole, GL_COMPILE);
glFrontFace(GL_CW);
glCallList(edge);
glNormal3f(0.0, 0.0, -1.0);
glCallList(side);
glPushMatrix();
glTranslatef(0.0, 0.0, thickness);
glFrontFace(GL_CCW);
glNormal3f(0.0, 0.0, 1.0);
glCallList(side);
glPopMatrix();
glEndList();
}