changed LightBounce to use display list for each logo

git-svn-id: svn://anubis/dwscr/trunk@99 5bef9df8-b654-44bb-925b-0ff18baa8f8c
This commit is contained in:
josh 2008-11-13 16:02:14 +00:00
parent c8940490ca
commit 1c41d64a3a
2 changed files with 24 additions and 12 deletions

View File

@ -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();

View File

@ -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