Search code examples
performanceopenglobject-modeldisplaylist

Anything wrong using display lists in OpenGL for a single object?


First of all, I know that displays lists were deprecated in OpenGL 3.0 and removed on 3.1. But I still have to use them on this university project for which OpenGL 2.1 is being used.

Every article or tutorial I read on display lists use them on some kind of object that is drawn multiple times, for instance, trees. Is there anything wrong in creating one list for a single object?

For instance, I have an object (in .obj format) for a building. This specific building is only drawn once. For basic performance analysis I have the current frames per second on the window title bar.

Doing it like this:

glmDraw(objBuilding.model, GLM_SMOOTH | GLM_TEXTURE);

I get around 260 FPS. If you don't about the GLM library, the glmDraw function basically makes a bunch of glVertex calls.

But doing it like this:

glNewList(gameDisplayLists.building, GL_COMPILE);
    glmDraw(objBuilding.model, GLM_SMOOTH | GLM_TEXTURE);
glEndList();

glCallList(gameDisplayLists.building);

I get around 420 FPS. Of course, the screen refresh rate doesn't refresh that fast but like I said, it's just a simple and basic way to measure performance.

It looks much better to me.

I'm also using display lists for when I have some type of object that I repeat many times, like defense towers. Again, is there anything wrong doing this for a single object or can I keep doing this?


Solution

  • Using display lists for this stuff is perfectly fine and before Vertex Arrays were around they were the de-facto standard to place geometry in fast memory. Put display lists have a few interesting pitfalls. For example in OpenGL-1.0 there were no texture objects; instead placing the glTexImage call in a display list was the way to emulate this. And this behaviour still prevails, so binding a texture and calling glTexImage in a display list will effectively re-initialize the texture object with what's been done in the display list compilation, whenever the display list is called. On the other hand display lists don't work with vertex arrays.

    TL;DR: If your geometry is static, you don't expect to transistion to OpenGL-3 core anytime and it gives you a huge performance increase (like it did for you), then just use them!