I have such a code:
static QList<display_list*> displayLists;
static QList<display_list*> displayLists;
To copy to clipboard, switch view to plain text mode
items are added this way:
list = new display_list();
list->new_list(GL_COMPILE);
glBegin(GL_QUADS);
...
glEnd();
list->end_list();
displayLists.append(list);
list = new display_list();
list->new_list(GL_COMPILE);
glBegin(GL_QUADS);
...
glEnd();
list->end_list();
displayLists.append(list);
To copy to clipboard, switch view to plain text mode
The problem is if I need to clear list and generate otehr display lists than displayLists.clear() is a bad choice - ~display_list() is not called for elements, in fact lists still reside in OpenGL memory. Currently I have such a header in function, that generates this list:
void prepareLists()
{
if(!displayLists.isEmpty())
foreach(display_list* ptr, displayLists) delete ptr;
displayLists.clear();
...
void prepareLists()
{
if(!displayLists.isEmpty())
foreach(display_list* ptr, displayLists) delete ptr;
displayLists.clear();
...
To copy to clipboard, switch view to plain text mode
but I don't like it 
Any ideas how to make it nice&clean?
PS: display_list is not a QObject
Bookmarks