PDA

View Full Version : Problem with display lists



arian487
11-23-2011, 02:53 PM
So My program needs to use display lists since I'd doing a ton of stuff. But when I add the display list what is drawn on screen looks like it isn't all of my model. (I can screenshot if need be).

Basically this is how i set it up:



void Mesh::walk_gl(bool picking) const
{
if (should_display_list) {
index_display_list = glGenLists(1);
glNewList(index_display_list, GL_COMPILE);
for (int i = 0; i < m_faces.size(); i++) {
int vertex_index = -1;
int normal_index = -1;
int texture_index = -1;
Face face;
face = m_faces[i];
glBegin(GL_POLYGON);
for (int j = 0; j < m_faces[i].vertice_index.size(); j++) {
vertex_index = face.vertice_index[j];
// std::cout<<face.vertice_index.size()<<std::endl;
// std::cout<<face.vertice_index.size()<<std::endl;
if (face.normal_index.size() != 0)
normal_index = face.normal_index[j];
if (face.texture_index.size() != 0)
texture_index = face.texture_index[j];
if (normal_index != -1)
glNormal3f(m_normals[normal_index][0], m_normals[normal_index][1], m_normals[normal_index][2]);
if (texture_index != -1)
glTexCoord2f (m_textures[texture_index][0],m_textures[texture_index][1]);
glVertex3f(m_verts[vertex_index][0],m_verts[vertex_index][1],m_verts[vertex_index][2]);

}
glEnd();
glEndList();
should_display_list = false;
}
}
glCallList(index_display_list);

glFlush();
}


Basically what I do is, on the first call to drawing my mesh, I create the display list and then on subsequent calls, I just make the display list. The index_display_list and the boolean to see whether or not to create the list are just globals. I'm not sure what I'm doing wrong and my experience with display lists is small. Any ideas what I might be doing wrong?

arian487
11-23-2011, 03:16 PM
Oh god I'm a dumbass. The glEndList was in the wrong place...