Farcaller
23rd January 2006, 19:08
I have such a code:
static QList<display_list*> displayLists;
items are added this way:
list = new display_list();
list->new_list(GL_COMPILE);
glBegin(GL_QUADS);
...
glEnd();
list->end_list();
displayLists.append(list);
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();
...
but I don't like it :confused:
Any ideas how to make it nice&clean?
PS: display_list is not a QObject
static QList<display_list*> displayLists;
items are added this way:
list = new display_list();
list->new_list(GL_COMPILE);
glBegin(GL_QUADS);
...
glEnd();
list->end_list();
displayLists.append(list);
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();
...
but I don't like it :confused:
Any ideas how to make it nice&clean?
PS: display_list is not a QObject