Scott Francis
05-22-2000, 01:02 PM
I've been writing a Videoscape file reader to play around with. I've managed to get it to read the information into custom arrays(with vertex information in Vertex objects of float xyz coords, and faces(planes) of the object in objects containing how many vertices in the face, and an array of 3-4 Vertex objects).
However, when I go to build the display list, the resulting object comes out wonky. A pyramid has two points, a cube has some faces drawn correctly but others with holes, etc.
I suspect that I'm overlooking something simple when writing the glVertexes. Here's the section that builds the list; nplanes is the number of faces, and planes is the array of face objects:
mesh = glGenLists(1);
printf("Now building display list.\n");
glNewList(mesh, GL_COMPILE);
/* The nplanes loop */
for(i = 0; i <= (nplanes-1); i++){
if(planes[i].numVerts == 3){
count = 2;
glBegin(GL_TRIANGLES);
}
else if(planes[i].numVerts == 4){
count = 3;
glBegin(GL_QUADS);
}
else{
/* shouldn't happen */
count = 4;
glBegin(GL_POLYGON);
}
/* generic coloring for now */
glColor3f(1.0f, 1.0f, 0.0f);
/* Individual plane loop */
for(j = 0; j <= count; j++){
glVertex3f(planes[i].vertexes[j].x,planes[i].vertexes[j].y, planes[i].vertexes[j].z);
}
glEnd();
}
glEndList();
return mesh;
However, when I go to build the display list, the resulting object comes out wonky. A pyramid has two points, a cube has some faces drawn correctly but others with holes, etc.
I suspect that I'm overlooking something simple when writing the glVertexes. Here's the section that builds the list; nplanes is the number of faces, and planes is the array of face objects:
mesh = glGenLists(1);
printf("Now building display list.\n");
glNewList(mesh, GL_COMPILE);
/* The nplanes loop */
for(i = 0; i <= (nplanes-1); i++){
if(planes[i].numVerts == 3){
count = 2;
glBegin(GL_TRIANGLES);
}
else if(planes[i].numVerts == 4){
count = 3;
glBegin(GL_QUADS);
}
else{
/* shouldn't happen */
count = 4;
glBegin(GL_POLYGON);
}
/* generic coloring for now */
glColor3f(1.0f, 1.0f, 0.0f);
/* Individual plane loop */
for(j = 0; j <= count; j++){
glVertex3f(planes[i].vertexes[j].x,planes[i].vertexes[j].y, planes[i].vertexes[j].z);
}
glEnd();
}
glEndList();
return mesh;