View Full Version : glNewList - call more than once per list?

06-16-2010, 12:25 AM

Im not clear from the specifications if it is allowed to call glNewList more than once following glGenLists. Basically from time to time I would like to recompile lists (to change the content), without having to realloc.

This would make a big difference to my design as it seems glNewList + COMPILE is fast, whereas glGenLists + glDeleteLists is relatively expensive (understandably).

Does anyone know what the official spec is here?

thanks in advance!

06-17-2010, 08:54 AM
It is not possible to do what you are intend to without heavy memory leak.

But let's go to beginning....

glGenLists is not an expensive operation, as you think. Because it does not "generate" list. It retrieves IDs which you can use for your lists (and grantees that they are unique). Earlier those IDs could be frivolously chosen, without calling glGen*. But it is preferable to leave it to OpenGL. Nowadays drivers (in core profile) usually disallow using IDs that are not retrieved by glGen*.

glEndList (that follows some glNewList) should replace existing DL with the same ID, according to MSDN ( http://msdn.microsoft.com/en-us/library/dd373952(VS.85).aspx ), but there is no evidence of such behavior neither in spec nor in vendors documentation. If it works like MSDN claims it must implicitly call glDeleteLists in order to avoid memory leak.

My advice is to call glDeleteLists before another glNewList for the same ID.

The second option is to switch to VBOs. There is no compiling. :)