Display Lists and Not Display Lists

Started by
6 comments, last by Nathan Baum 16 years, 9 months ago
Hi, I have some code:
glLoadIdentity()
glTranslatef(-0.129, 0.197, -0.5)
glCallList(4)
glTranslatef(-0.127, 0.0, 0.0)
glColor4f(1.0, 1.0, 1.0, 0.5)
size = 0.008
if timeleft > 19.5:
    timeleft = 19.5
glBegin(GL_QUADS)
glVertex3f(0.0*size, -1.0*size, 0)
glVertex3f(timeleft*size, -1.0*size, 0)
glVertex3f(timeleft*size, 1.0*size, 0)
glVertex3f(0.0*size, 1.0*size, 0)
glEnd()
glColor4f(1.0, 1.0, 1.0, 1.0)
but if I comment out glCallList(4), the quad is not drawn! Why not? Here's the code for display list 4:
size = .01
glGenLists(1)
glNewList(4, GL_COMPILE)
glBindTexture(GL_TEXTURE_2D, textures[0])
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, selfSurface.get_width(), selfSurface.get_height(), 0,
              GL_RGBA, GL_UNSIGNED_BYTE, selfData )
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glBegin(GL_QUADS)
glTexCoord2f(0.0, 0.0); glVertex3f(-12.9636*size, -1.0*size, 0.0)
glTexCoord2f(1.0, 0.0); glVertex3f(12.9636*size, -1.0*size, 0.0)
glTexCoord2f(1.0, 1.0); glVertex3f(12.9636*size, 1.0*size, 0.0)
glTexCoord2f(0.0, 1.0); glVertex3f(-12.9636*size, 1.0*size, 0.0)
glEnd();
glEndList()

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Advertisement
Do you mean the latter quad, since commenting out glCallList(4) will of course disable the rendering of the quad you've compiled to the drawlist 4?

If you mean the latter quad, it seems to have no texture coordinates, so you should disable the GL_TEXTURE_2D (I assume you have it enabled since your call list quad has texture coordinates) before rendering it.
When you render the call list quad, the texture coordinate for every vertex of the secondary quad is same which was the last texture coordinate for the call list quad, and if the texturing is enabled the whole quad will be textured with one texel and it becomes visible. If you disable the call list quad, and draw the secondary quad, every texture coordinate will be most likely 0,0 if you haven't set any texture coordinates previously.
Yes, the latter quad; the one whose drawing code was not commented out.

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

See modified post, I tried to figure out something.
THAT WORKS! Thanks! (Note that one must add "glEnable(GL_TEXTURE_2D)" after the quad has been rendered!) This also fixes some issues I've been having with color.

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

In creating your list, you are also uploading the date for the texture. You should not be doing this, it will cause speed problems later, and may or may not be causing your current problem.

I think that's your problem. The texture isn't being uploaded (all the calls in the compiling of the display list arent' actually called until you call glCallList, so the texture is never uploaded when you comment out the list call).

Hope that helps
~Zix

[Edited by - zix99 on July 10, 2007 4:40:33 PM]
---------------------------------------------------Game Programming Resources, Tutorials, and Multimedia | Free Skyboxes
The problem was already solved, but yes, I know what you are talking about. strangely enough, the other way makes it run slower!

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Quote:Original post by Geometrian
The problem was already solved, but yes, I know what you are talking about. strangely enough, the other way makes it run slower!

Looks like this depends upon your GL implementation and what you're doing in the display list. On my system, using display lists incurs a slight but constant penalty. Using them for setting up textures is quite a bit slower than just using texture names, but using them for setting up other kinds of state (e.g. matrices, shaders, lighting) is a little bit faster than setting that state up manually, although of course it's faster if you can avoid setting the state at all.

This topic is closed to new replies.

Advertisement