added Flip mode (in progress)
This commit is contained in:
parent
6cd00909e0
commit
f31a7ebb7a
3
dwss.cc
3
dwss.cc
@ -35,7 +35,8 @@ int main (int argc, char *argv[])
|
||||
GnomeScreensaver gs(&argc, &argv, configure, expose, update, 12);
|
||||
|
||||
Mode *modes[] = {
|
||||
new Spin()
|
||||
new Spin(),
|
||||
new Flip()
|
||||
};
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
64
modes/Flip.cc
Normal file
64
modes/Flip.cc
Normal file
@ -0,0 +1,64 @@
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
#include "Flip.h"
|
||||
|
||||
#define FLIP_TICKS 1000
|
||||
#define STATIC_TICKS 200
|
||||
#define SPAN_Y 5
|
||||
|
||||
Flip::Flip()
|
||||
{
|
||||
m_state = WAITING;
|
||||
m_span_x = 6;
|
||||
m_span_y = 5;
|
||||
}
|
||||
|
||||
bool Flip::expose (GnomeScreensaver & gs)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glTranslatef(m_x, m_y, 0.0);
|
||||
m_logobox.draw();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Flip::configure (GnomeScreensaver & gs)
|
||||
{
|
||||
glViewport(0, 0, gs.getWidth(), gs.getHeight());
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(60.0, gs.getAspectRatio(), 0.01, 1000.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt(0, 0, SPAN_Y * m_logobox.getDepth(), 0, 0, 0, 0, 1, 0);
|
||||
|
||||
m_span_x = (int) (m_span_y * gs.getAspectRatio()
|
||||
/ (m_logobox.getWidth() / m_logobox.getDepth()) + 0.5);
|
||||
m_y = 0.0f;
|
||||
m_x = -(1 - (m_span_x & 0x1)) * m_logobox.getWidth() / 2.0;
|
||||
m_last_ticks = gs.getTicks();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Flip::update (GnomeScreensaver & gs)
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
case WAITING:
|
||||
break;
|
||||
case FLIPPING:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
31
modes/Flip.h
Normal file
31
modes/Flip.h
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
#ifndef FLIP_H
|
||||
#define FLIP_H
|
||||
|
||||
#include "LogoBox.h"
|
||||
#include "Mode.h"
|
||||
#include "GnomeScreensaver.h"
|
||||
|
||||
class Flip : public Mode
|
||||
{
|
||||
public:
|
||||
typedef enum
|
||||
{
|
||||
WAITING,
|
||||
FLIPPING
|
||||
} State;
|
||||
Flip();
|
||||
bool expose (GnomeScreensaver & gs);
|
||||
bool configure (GnomeScreensaver & gs);
|
||||
bool update (GnomeScreensaver & gs);
|
||||
protected:
|
||||
LogoBox m_logobox;
|
||||
State m_state;
|
||||
int m_span_x, m_span_y;
|
||||
float m_x, m_y;
|
||||
int m_flip_direction;
|
||||
int m_last_ticks;
|
||||
};
|
||||
|
||||
#endif /* FLIP_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user