using common LogoBox object in LightBounce mode

git-svn-id: svn://anubis/dwscr/trunk@98 5bef9df8-b654-44bb-925b-0ff18baa8f8c
This commit is contained in:
josh 2008-11-13 15:54:31 +00:00
parent 2ba3ce27b4
commit c8940490ca
2 changed files with 16 additions and 14 deletions

View File

@ -29,11 +29,6 @@ LightBounceBox::LightBounceBox(LogoBox * lb,
this->dist = 0.0; this->dist = 0.0;
} }
LightBounceBox::~LightBounceBox()
{
delete this->logoBox;
}
/* construct screensaver mode and do some basic OpenGL setup */ /* construct screensaver mode and do some basic OpenGL setup */
LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain) LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
{ {
@ -47,8 +42,7 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
1000.01); 1000.01);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
LogoBox tmp; float box_stride = m_logoBox.getWidth() * STRIDE_MULTIPLIER;
float box_stride = tmp.getWidth() * STRIDE_MULTIPLIER;
float half_size = SIZE * box_stride / 2.0; float half_size = SIZE * box_stride / 2.0;
float y = -half_size + box_stride / 2.0; float y = -half_size + box_stride / 2.0;
int rot = false; int rot = false;
@ -59,32 +53,32 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
{ {
// front // front
LightBounceBox * box = new LightBounceBox( LightBounceBox * box = new LightBounceBox(
new LogoBox(), x, y, -half_size, 0, 180.0, rot ? 90.0 : 0 &m_logoBox, x, y, -half_size, 0, 180.0, rot ? 90.0 : 0
); );
m_boxes.push_back(box); m_boxes.push_back(box);
// right // right
box = new LightBounceBox( box = new LightBounceBox(
new LogoBox(), half_size, y, x, 0, 90.0, rot ? 0 : 90.0 &m_logoBox, half_size, y, x, 0, 90.0, rot ? 0 : 90.0
); );
m_boxes.push_back(box); m_boxes.push_back(box);
// back // back
box = new LightBounceBox( box = new LightBounceBox(
new LogoBox(), x, y, half_size, 0, 0, rot ? 90.0 : 0 &m_logoBox, x, y, half_size, 0, 0, rot ? 90.0 : 0
); );
m_boxes.push_back(box); m_boxes.push_back(box);
// left // left
box = new LightBounceBox( box = new LightBounceBox(
new LogoBox(), -half_size, y, x, 0, 270.0, rot ? 0 : 90.0 &m_logoBox, -half_size, y, x, 0, 270.0, rot ? 0 : 90.0
); );
m_boxes.push_back(box); m_boxes.push_back(box);
// top // top
box = new LightBounceBox( box = new LightBounceBox(
new LogoBox(), x, half_size, y, 270, 0, rot ? 0 : 90.0 &m_logoBox, x, half_size, y, 270, 0, rot ? 0 : 90.0
); );
m_boxes.push_back(box); m_boxes.push_back(box);
// bottom // bottom
box = new LightBounceBox( box = new LightBounceBox(
new LogoBox(), x, -half_size, y, 90, 0, rot ? 0 : 90.0 &m_logoBox, x, -half_size, y, 90, 0, rot ? 0 : 90.0
); );
m_boxes.push_back(box); m_boxes.push_back(box);
@ -95,6 +89,13 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
} }
} }
LightBounce::~LightBounce()
{
int sz = m_boxes.size();
for (int i = 0; i < sz; i++)
delete m_boxes[i];
}
/* called every time this screensaver mode should redraw the screen */ /* called every time this screensaver mode should redraw the screen */
void LightBounce::update() void LightBounce::update()
{ {

View File

@ -18,7 +18,6 @@ public:
LightBounceBox(LogoBox * lb, LightBounceBox(LogoBox * lb,
float x, float y, float z, float x, float y, float z,
float xr, float yr, float zr); float xr, float yr, float zr);
~LightBounceBox();
LogoBox * logoBox; LogoBox * logoBox;
float x; float x;
float y; float y;
@ -33,9 +32,11 @@ class LightBounce : public SSMode
{ {
public: public:
LightBounce(SSMain * _SSMain); LightBounce(SSMain * _SSMain);
~LightBounce();
void update(); void update();
protected: protected:
vector<LightBounceBox *> m_boxes; vector<LightBounceBox *> m_boxes;
LogoBox m_logoBox;
}; };
#endif #endif