diff --git a/ss/LightBounce.cc b/ss/LightBounce.cc index 0a068b7..26e4e6b 100644 --- a/ss/LightBounce.cc +++ b/ss/LightBounce.cc @@ -19,7 +19,6 @@ LightBounceBox::LightBounceBox(LogoBox * lb, float x, float y, float z, float xr, float yr, float zr) { - this->logoBox = lb; this->x = x; this->y = y; this->z = z; @@ -27,6 +26,22 @@ LightBounceBox::LightBounceBox(LogoBox * lb, this->yr = yr; this->zr = zr; this->dist = 0.0; + + m_dl = glGenLists(1); + glNewList(m_dl, GL_COMPILE); + glPushMatrix(); + glTranslatef(x, y, z); + glRotatef(xr, 1, 0, 0); + glRotatef(yr, 0, 1, 0); + glRotatef(zr, 0, 0, 1); + lb->draw(); + glPopMatrix(); + glEndList(); +} + +LightBounceBox::~LightBounceBox() +{ + glDeleteLists(m_dl, 1); } /* construct screensaver mode and do some basic OpenGL setup */ @@ -113,15 +128,7 @@ void LightBounce::update() int sz = m_boxes.size(); for (int i = 0; i < sz; i++) { - glPushMatrix(); - glTranslatef(m_boxes[i]->x, - m_boxes[i]->y, - m_boxes[i]->z); - glRotatef(m_boxes[i]->xr, 1, 0, 0); - glRotatef(m_boxes[i]->yr, 0, 1, 0); - glRotatef(m_boxes[i]->zr, 0, 0, 1); - m_boxes[i]->logoBox->draw(); - glPopMatrix(); + m_boxes[i]->draw(); } } SDL_GL_SwapBuffers(); diff --git a/ss/LightBounce.h b/ss/LightBounce.h index 39dc4e4..664dbdf 100644 --- a/ss/LightBounce.h +++ b/ss/LightBounce.h @@ -18,14 +18,19 @@ public: LightBounceBox(LogoBox * lb, float x, float y, float z, float xr, float yr, float zr); - LogoBox * logoBox; + ~LightBounceBox(); + void draw() { glCallList(m_dl); } + float dist; + +private: float x; float y; float z; float xr; float yr; float zr; - float dist; + + GLuint m_dl; }; class LightBounce : public SSMode