Christian Vucossa programming blog

game programming, daily troubles and solutions

OpenGL: how Display Lists can improve performaces

Posted by Christian on December 10, 2008

I’m actually working on a 3D version of Pong, using OpenGL via SDL and coding in C++ under my linux Ubuntu.

This simple game is a great exercise and I’m using it to develop some common routines such as a mesh loader for .x files and related mesh renderer. So I’m having the opportunity to face a serious performance issue.

My scene is composed of about 2500 polys (a plane, 2 rackets and the ball), really low count, but enough to reduce my frames per second (fps) to 3 or 4. Ugh! My ball is moving really bad.

But OpenGL is fast! where is all the power? Well, the reason lays in my way to render polys.

My utility was rendering all the scene’s polys, one a time, between glBegin(…) and glEnd() commands.

This way, I was invoking glBegin() one time for every poly. Definitely not good.

What I did was change my rendering routine in order to use Display Lists.  This gave me a real boost of performances!

Now my fps are about 1000 and I have to face the opposite issue: too fast! But the real message is that OpenGL’s display lists works!

3 Responses to “OpenGL: how Display Lists can improve performaces”

  1. While display lists may work in the short term, they are a deprecated feature, and very outdated – as is the whole begin/end paradigm. You should consider switching to vertex arrays, and from there to vertex buffer objects, if you want to see OpenGL’s real power and performance ;)

  2. Christian said

    thanx for the suggestion Tristam. You mean I should use methods glVertexPointer and glDrawArrays instead? It’s not a bad idea. This way I can more easily edit vertex coordinates directly, right? Without perform matrix transformation to move an object I mean. I’m right?

  3. Not quite. For performance you want to draw as many vertices with a single draw call (glDrawArrays or glDrawElements) as possible – ideally not more than one call per object. Once you move to vertex buffer objects, the vertices will actually be uploaded into GPU memory, where they will not be changed, so you continue to use the matrix stack for transformations.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.