View Full Version : How many display lists can I create?

08-07-2006, 12:56 PM
My question is rather simple. I simply wonder if there is a way of querying the OpenGL context how many display lists I can create. I would like to do this in advance, instead of creating display lists until glGenLists(...) returns zero. Is there a way to do this?

08-07-2006, 01:09 PM
There is no limit other than the amount of resources available to store the display lists.

08-07-2006, 01:22 PM
I assume there is a limit as the number of lists approaches the integer value representable by a GLuint, alhtough this is an astronimically large numer and not a limitation for me.

What exactly is the amount of resources you are referring to?

08-07-2006, 01:31 PM
The maximum number representable by a GLuint, as youy said, is one resource that sets a limit. At least 4.2 billion lists. Other resources are available memory.

08-08-2006, 01:06 AM
Because on 32-bit OSes virtual address space runs out before you can even generate so many display lists IDs, the upper limit is just theoretical there.
If you're building huge amounts of display lists it's important that you monitor the successful build. You need to put a glGetError after each glEndList to catch out-of-memory errors!
If that happened, you need to free some memory or could fallback to vertex arrays or worse, immediate mode. Performance might be gone anyway under those low memory conditions.
64-bit OSes rule. ;)

08-08-2006, 08:04 PM
Not sure I follow you on the virtual address space but I guess it's more of a C++ topic than an OpenGL topic. Although it seems proven that this restriction actually applies to OpenGL programming (when using C++ of course).

What I don't follow is how glGetError could catch an error that has to do with virtual address space. As you say the virtual address space is managed by the OS so it doesn't make sense to me at this stage.

I would love an explanation on this one! :-)

Thanks for the quick replies!

08-09-2006, 01:14 AM
With 32 bit addresses you can only have a max of 4GB adressable (per process).
GLuint is the type for display list IDs and 32 bit as well. Generating the 4G * 4 bytes IDs alone will not fit into your address space.

Under Windows 32-bit system the adress space is normally divided between user and kernel space at 2GB each. You can set a boot option which changes that to 3GB user and 1GB kernel space, but that's it and your app needs to be aware of these large user adresses.
Applications allocating huge amounts of data hit this 3GB limit already (thinking about a CAD app rendering a power plant or special effects SW for movie rendering with hundreds or thousands of animated people. Think about the extras in Matrix or Lord of the Rings.). There will always be a bigger scene not fitting into the 32-bit space. These applications likely use 64-bit OSes already.
A display list build will fail in your process if you exhausted the memory in that way and the only option in the OpenGL implementation is to fail the display list compilation and return GL_OUT_OF_MEMORY. And your only option is to catch that with glGetError and handle the failure in your application.