Display list behavior question

I just wanted to know what the default behavior, if any, of a display list in the event of the following sequence of calls (all calls here are just illustrated for order, not syntax):

//////////////////////////////////////

glGenLists(foo);
glNewList(foo);

// What happens now:

glNewList(foo);
// … Any number more of glNewList(foo)'s
// …

glDeleteLists(foo);

//////////////////////////////////////

My question is, after the list is generated, the first glNewList fills the list. Am I leaking any memory by the subsequent glNewList calls, or am I automagically deleting any memory used by the previous list and reusing/replacing it with the new one?

I ask this question because it gets kindof hard to track the glGenLists/glNewList/glDeleteList cycles, and having to delete a list (or lists) and regenerate all associated lists would be very annoying.

One point I must make is that I haven’t had any adverse effects using the type of code I’ve just questioned. I would like to know whether or not this will break on other video systems down the road.

Thanks in advance for anyone and everyone looking into this with me.

Siwko

(I know each implementation is different, but hey, you never know.)

It is not good practice to do that. I am sure you will get issue someday with another card.

I haven’t read anywhere that the display list deallocate themselves if you don’t call deletelist, so you’ll probably end up with memory leaks.

Destroy your list before creating a new one. Don’t take any chances. You could encapsulate all that in a function or in a class.

So you call your custom function createlist() that checks if there is list before allocating it.

I’m not talking about issuing a new glGenLists with the same index here, as I absolutely know that doesn’t work properly. I think you end up running out of environment space for the lists.

As per the code above, I’m simply generating a new list atop of an old one.

I too am fairly certain that over time, some issue will crop up with this, but I haven’t had enough time to experiment (unfortunately I’m working on a closed company project in which pretty much video-wise I’m only developing for a single target platform).

Anyone else have any thoughts on it?

Siwko