00001 #include "dlist.h" 00002 00007 #if !defined(NDEBUG) 00008 #include <iostream> 00009 #endif 00010 00011 #include <cassert> 00012 using namespace std; 00013 00014 GltDisplayList::GltDisplayList() 00015 : _list(-1) 00016 { 00017 } 00018 00019 GltDisplayList::~GltDisplayList() 00020 { 00021 #if !defined(NDEBUG) 00022 if (defined()) 00023 cerr << "WARNING: Potential OpenGL display list leak (" << this << ")" << endl; 00024 #endif 00025 00026 reset(); 00027 } 00028 00029 bool 00030 GltDisplayList::defined() const 00031 { 00032 return _list!=-1; 00033 } 00034 00035 void 00036 GltDisplayList::draw() const 00037 { 00038 if (_list!=-1) 00039 glCallList(_list); 00040 } 00041 00042 void 00043 GltDisplayList::reset() 00044 { 00045 if (_list!=-1) 00046 { 00047 glDeleteLists(_list,1); 00048 _list = -1; 00049 } 00050 } 00051 00052 void 00053 GltDisplayList::newList(GLenum mode) 00054 { 00055 if (_list==-1) 00056 _list = glGenLists(1); 00057 00058 assert(_list!=-1); 00059 00060 glNewList(_list,mode); 00061 } 00062 00063 void 00064 GltDisplayList::endList() 00065 { 00066 glEndList(); 00067 }