tags:

views:

29

answers:

1

If an existing compiled display list is to be recompiled, is it necessary to call glDeleteLists() and glGenLists() first? Or can the display list be recompiled by just calling glNewList() on the existing compiled display list ID?

+1  A: 

Just calling glNewList/glEndList should be enough.

Note that the deletion only becomes effective on the glEndList call:

If a  display list with name `list` already exists, 
it is replaced only when glEndList is called.

If you'd rather have the previous list freed earlier, then by all means, do call glDeleteLists. Being explicit certainly does not hurt.

Last bit... glGenLists is never required. You can always call glNewList on any positive integer, even if it was not provided through glGenLists. The main reason for the glGenLists API is to make sure the name is not already in use. But you already know that if you just deleted it.

Bahbar
So not calling glDeleteLists() won't cause some sort of server-side memory leak? Also, does it work the same for other server-side objects like textures, buffer objects, etc.?
jay.lee
not calling Delete* on an object before reallocating that handle should not leak (but bugs in implementations can exist). It's part of GL's job to make sure it does not leak there. It's true for all objects where you can decide the name (like textures and buffer objects).
Bahbar