added a LightBounceBoxComparator to order logos by distance from viewer

git-svn-id: svn://anubis/dwscr/trunk@102 5bef9df8-b654-44bb-925b-0ff18baa8f8c
This commit is contained in:
josh 2008-11-13 19:23:30 +00:00
parent 47c652a150
commit aac98e8699
2 changed files with 17 additions and 0 deletions

View File

@ -52,6 +52,13 @@ void LightBounceBox::updateDist(float x, float y, float z)
this->dist = (dx*dx) + (dy*dy) + (dz*dz);
}
bool LightBounceBoxComparator::operator()(LightBounceBox * l1, LightBounceBox * l2)
{
return l1->getDist() > l2->getDist();
}
/* construct screensaver mode and do some basic OpenGL setup */
LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
{
@ -112,6 +119,7 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
}
glPushAttrib(GL_POLYGON_BIT); /* store CULL_FACE settings */
// glEnable(GL_BLEND);
}
LightBounce::~LightBounce()
@ -142,6 +150,7 @@ void LightBounce::update()
{
m_boxes[i]->updateDist(viewer_x, viewer_y, viewer_z);
}
sort(m_boxes.begin(), m_boxes.end(), m_comparator);
for (int i = 0; i < numMonitors; i++)
{

View File

@ -21,6 +21,7 @@ public:
~LightBounceBox();
void draw() { glCallList(m_dl); }
void updateDist(float x, float y, float z);
float getDist() { return dist; }
private:
float x;
@ -34,6 +35,12 @@ private:
GLuint m_dl;
};
class LightBounceBoxComparator
{
public:
bool operator()(LightBounceBox * l1, LightBounceBox * l2);
};
class LightBounce : public SSMode
{
public:
@ -41,6 +48,7 @@ public:
~LightBounce();
void update();
protected:
LightBounceBoxComparator m_comparator;
vector<LightBounceBox *> m_boxes;
LogoBox m_logoBox;
};