No Im doin it myself, all in C++. This is my mistake, I was asking for help and I didn’t really know what questions to ask yet because I was frustrated. My project is more about a flexible interface for the user to view an enviroment. But I noticed the tess functions would be very handy in my project, which is mostly drawing a detailed building. So I wanted to use the tess functions to draw my walls with all the doors and windows cut out, so I could map my textures onto the entire wall, etc.
But the problem is now I really can’t figure out why I cant make the simplest of polygons with the tessellation functions. I havent found many topics online specifically about this.
I’ve taken most of this code from the red book and I’ve been toying with it in several ways, but if you can see anything obviously wrong, please elaborate.
This is just supposed to draw a big wall, with 1 small hole in it, but nothing is drawn at all. I draw an outline around where the wall should be, and its fine, so I know Im not using the tess functions properly.
GLdouble rec1[3] = {0.0, 0.0, 0.0};
GLdouble rec2[3] = {0.0, 65.0, 0.0};
GLdouble rec3[3] = {0.0, 65.0, -250.0};
GLdouble rec4[3] = {0.0, 0.0, -250.0};
GLdouble win1[3] = {0.0, 5.0, -5.0};
GLdouble win2[3] = {0.0, 25.0, -5.0};
GLdouble win3[3] = {0.0, 25.0, -25.0};
GLdouble win4[3] = {0.0, 5.0, -25.0};
GLvoid tcbBegin(GLenum type)
{
glBegin(type);
}
GLvoid tcbVertex(GLvoid *vertex)
{
const GLdouble* pointer;
pointer = (GLdouble*)vertex;
glColor3dv(pointer+3);
glVertex3dv((GLdouble*)vertex);
}
GLvoid tcbEnd()
{
glEnd();
}
GLvoid combineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut )
{
GLdouble *vertex;
int i;
vertex = (GLdouble *) malloc(6 * sizeof(GLdouble));
vertex[0] = coords[0];
vertex[1] = coords[1];
vertex[2] = coords[2];
for (i = 3; i < 7; i++)
vertex[i] = weight[0] * vertex_data[0][i]
+ weight[1] * vertex_data[1][i]
+ weight[2] * vertex_data[2][i]
+ weight[3] * vertex_data[3][i];
*dataOut = vertex;
}
GLvoid errorCallback(GLenum errorCode)
{
const GLubyte *estring;
estring = gluErrorString(errorCode);
fprintf(stderr, "Tessellation Error: %s
", estring);
exit(0);
}
void init()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
gluPerspective(fov_degrees, xy_ratio, near_clip, far_clip);
gluLookAt(eye_x, eye_y, eye_z, focus_x, focus_y, focus_z, 0.0, 1.0, 0.0);
glMatrixMode(GL_MODELVIEW);
glShadeModel(GL_FLAT);
wall1 = gluNewTess();
gluTessCallback(wall1, GLU_TESS_VERTEX, (GLvoid)glVertex3dv);
gluTessCallback(wall1, GLU_TESS_BEGIN, (GLvoid)tcbBegin);
gluTessCallback(wall1, GLU_TESS_END, (GLvoid)tcbEnd);
gluTessCallback(wall1, GLU_TESS_COMBINE, (GLvoid)combineCallback);
gluTessCallback(wall1, GLU_TESS_ERROR, (GLvoid)errorCallback);
glShadeModel(GL_FLAT);
}
void window()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gluTessProperty(wall1,GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
gluTessBeginPolygon(wall1, NULL);
gluTessBeginContour(wall1);
gluTessVertex(wall1, rec1, rec1);
gluTessVertex(wall1, rec2, rec2);
gluTessVertex(wall1, rec3, rec3);
gluTessVertex(wall1, rec4, rec4);
gluTessEndContour(wall1);
gluTessBeginContour(wall1);
gluTessVertex(wall1, win1, win1);
gluTessVertex(wall1, win2, win2);
gluTessVertex(wall1, win3, win3);
gluTessVertex(wall1, win4, win4);
gluTessEndContour(wall1);
gluTessEndPolygon(wall1);
glFlush();
}
I suspected that the combineCallback function was not appropriate for this, but I also loaded the red book’s “tess.c” verbatum, modified slightly to compile, and that also displayed nothing. It was supposed to display a quad with a triangular hole and a contour 5 pointed star.
Anyway, see anything obvious? Thanks ahead of time