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;
}
LightBounceBox::~LightBounceBox()
{
delete this->logoBox;
}
/* construct screensaver mode and do some basic OpenGL setup */
LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
{
@ -47,8 +42,7 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
1000.01);
glMatrixMode(GL_MODELVIEW);
LogoBox tmp;
float box_stride = tmp.getWidth() * STRIDE_MULTIPLIER;
float box_stride = m_logoBox.getWidth() * STRIDE_MULTIPLIER;
float half_size = SIZE * box_stride / 2.0;
float y = -half_size + box_stride / 2.0;
int rot = false;
@ -59,32 +53,32 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
{
// front
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);
// right
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);
// back
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);
// left
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);
// top
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);
// bottom
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);
@ -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 */
void LightBounce::update()
{

View File

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