proj home

Files   Classes   Functions   Hierarchy  

gobjbase.cpp

Go to the documentation of this file.
00001 #include <gobjbase.h>
00002 
00003 gobjContainer * gobj::global = 0;
00004 
00005 
00006 vector< gobjContainer * > gobjContainer::globalvec;
00007 
00008 void gobjContainer::globalpop()
00009 { 
00010   assert(globalvec.empty()==false); 
00011   gobj::global =
00012     globalvec[globalvec.size()-1]; 
00013   globalvec.pop_back();
00014 }
00015 
00016 
00017 gobjglCallList<GLuint> * gobjContainer::displaylistcreatenew
00018 (
00019   uintc id
00020 )
00021 {
00022   GLuint listName = glGenLists(id);
00023   gobjglCallList<GLuint> * gcl = 
00024     new gobjglCallList<GLuint>(listName);
00025   glNewList(listName,GL_COMPILE);
00026   
00027   draw();
00028 
00029   glEndList();
00030 
00031   return gcl;
00032 }
00033 
00034 gobj::~gobj()
00035 {
00036 }
00037 
00038 void gobj::globaldisplaylist(uintc id)
00039 { 
00040   assert(global!=0); 
00041   global->displaylist(id); 
00042 }
00043 
00044 void gobjContainer::displaylist(uintc id)
00045 {  
00046   if (vg.empty()) 
00047     return; 
00048 
00049   gobj * x = displaylistcreatenew(id); 
00050   nuke(); 
00051   cleanup=true; 
00052   push(x); 
00053 }
00054 
00055 void gobjContainer::draw()
00056 {
00057   GOBJDEBUGCODE
00058 
00059   if (vg.empty())
00060     return;
00061 
00062   for (uint i=0; i<vg.size(); ++i)
00063     vg[i]->draw();
00064 }
00065 
00066 boolc gobjContainer::kill(uintc k)
00067 { 
00068   assert(k<vg.size());
00069   if (k>=vg.size()) 
00070     return false; 
00071   vg[k]=0; 
00072 
00073   return true; 
00074 } 
00075 
00076 boolc gobjContainer::kill(gobj* const targ)
00077 { 
00078   uint imax=vg.size();
00079   for (uint i=0; i<imax; ++i)
00080   {
00081     if (vg[i]==targ)
00082     {
00083       vg[i]=0;
00084       return true;
00085     }
00086   }
00087 
00088   return false; 
00089 } 
00090 
00091 gobjContainer::gobjContainer()
00092   : cleanup(true) 
00093 {
00094 };
00095 
00096 gobjContainer::gobjContainer(boolc cleanup_)
00097   : cleanup(cleanup_)
00098 {
00099 }
00100 
00101 void gobjContainer::nuke()
00102 {
00103   if (!cleanup)
00104   {
00105     vg.clear();
00106     return;
00107   }
00108 
00109   for (uint i=0; i<vg.size(); ++i)
00110   {
00111     delete vg[i];
00112     vg[i] = 0;
00113   }
00114   vg.clear();
00115 }
00116 
00117 gobjContainer::~gobjContainer()
00118 {
00119   nuke();
00120 }
00121 
00122 
00123 void gobjContainerdeque::draw()
00124 {
00125   GOBJDEBUGCODE
00126   if (vg.empty())
00127     return;
00128 
00129   for (uint i=0; i<vg.size(); ++i)
00130     vg[i]->draw();
00131 }
00132 
00133 void gobjContainerdeque::nuke()
00134 {
00135   if (!cleanup)
00136   {
00137     vg.clear();
00138     return;
00139   }
00140 
00141   for (uint i=0; i<vg.size(); ++i)
00142   {
00143     delete vg[i];
00144     vg[i] = 0;
00145   }
00146   vg.clear();
00147 }
00148 
00149 gobjContainerdeque::~gobjContainerdeque()
00150 {
00151   nuke();
00152 }
00153 
00154 
00155 gobjContainerSwitch::gobjContainerSwitch(boolc cleanup_)
00156   : gcontainer(cleanup_)
00157 {
00158 }
00159 
00160 gobjSwitch<> * gobjContainerSwitch::push( gobj * g )
00161 { 
00162   assert(g!=0); 
00163   gobjSwitch<> * gs = new gobjSwitch<>(g,true,gcontainer.cleanup);
00164   assert(gs!=0);
00165   gswitch.push_back(gs);
00166   gcontainer.vg.push_back(gs); 
00167 
00168   assert(gcontainer.vg.size()==gswitch.size());
00169 
00170   return gs;
00171 }
00172 
00173 //void gobjContainerSwitch::push( gobj * g )
00174 //{
00175 //  push_back(g);
00176 //}
00177 
00178 void gobjContainerSwitch::nuke()
00179 {
00180   uint sz=gswitch.size();
00181   for (uint i=0; i<sz; ++i)
00182     delete gswitch[i];
00183   gswitch.clear();
00184   gcontainer.vg.clear();
00185 }
00186 
00187 gobjContainerSwitch::~gobjContainerSwitch()
00188 {
00189   nuke();
00190 }
00191 
00192 void gobjContainerPrePost::draw()
00193 {
00194   GOBJDEBUGCODE
00195   pre.draw();
00196   gobjContainer::draw();
00197   post.draw();
00198 }
00199 
00200 
00201 

Generated on Fri Mar 4 00:49:27 2011 for Chelton Evans Source by  doxygen 1.5.8