rotate tunnel over time

This commit is contained in:
Josh Holtrop 2011-10-12 13:03:52 -04:00
parent 878b441742
commit 2f7858d60c
2 changed files with 10 additions and 0 deletions

View File

@ -18,6 +18,7 @@ using namespace std;
#define BREAKOFF_DIST 80
#define RING_LAYER_DIST 10
#define XLATE_RATE 0.02
#define REVOLUTION_TIME 15000
Tunnel::Tunnel()
{
@ -32,7 +33,10 @@ Tunnel::~Tunnel()
bool Tunnel::expose (GnomeScreensaver & gs)
{
if (m_last_ticks == 0)
{
m_last_ticks = gs.getTicks();
m_start_ticks = m_last_ticks;
}
uint64_t ticks = gs.getTicks();
int elapsed = ticks - m_last_ticks;
m_offset += XLATE_RATE * elapsed;
@ -44,6 +48,10 @@ bool Tunnel::expose (GnomeScreensaver & gs)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(360.0 *
((ticks - m_start_ticks) % REVOLUTION_TIME) / REVOLUTION_TIME,
0, 1, 0);
for (list<LBStruct>::const_iterator it = m_logos.begin();
it != m_logos.end();
it++)
@ -58,6 +66,7 @@ bool Tunnel::expose (GnomeScreensaver & gs)
m_logobox.draw();
glPopMatrix();
}
glPopMatrix();
m_last_ticks = ticks;

View File

@ -26,6 +26,7 @@ class Tunnel : public Mode
void addRing(double offset);
LogoBox m_logobox;
uint64_t m_last_ticks;
uint64_t m_start_ticks;
std::list<LBStruct> m_logos;
double m_offset;
double m_last_ring_offset;