added Spin mode -- in progress

This commit is contained in:
Josh Holtrop 2010-11-25 22:43:36 -05:00
parent 2544ff381a
commit e423d46c3e
4 changed files with 70 additions and 31 deletions

View File

@ -1,3 +1,4 @@
# vim:syntax=python
install_dir = '/usr/lib/gnome-screensaver/gnome-screensaver'
load_files = ['logo/dwlogo.obj', 'logo/dwlogo.mtl']
@ -18,7 +19,7 @@ def gen_modes(target, source, env):
genModes = Builder(action = gen_modes)
env.Append(BUILDERS = {'Modes' : genModes})
sources = [Glob('*.c'), Glob('*.cc'), Glob('LoadFile/*.cc')]
sources = [Glob('*.c'), Glob('*.cc'), Glob('LoadFile/*.cc'), Glob('modes/*.cc')]
env.LoadFile('LoadFile-gen.inc', load_files)
env.Depends('LoadFile-gen.inc', 'genLoadFile.pl')

40
dwss.cc
View File

@ -16,24 +16,11 @@ using namespace std;
#define MAX_ASPECT (16.0/9.0*1.02)
static int n_monitors = 1;
static Mode *current_mode;
static bool expose (GnomeScreensaver & gs)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(gs.getTicks()/1000.0*360.0, 0, 0, 1);
glBegin(GL_QUADS);
glColor3f(1, 0.6, 0);
glNormal3f(0, 0, 1);
glVertex2f(1, 1);
glVertex2f(-1, 1);
glVertex2f(-1, -1);
glVertex2f(1, 0);
glEnd();
glPopMatrix();
return true;
return current_mode->expose(gs);
}
static bool configure (GnomeScreensaver & gs, int width, int height)
@ -43,30 +30,23 @@ static bool configure (GnomeScreensaver & gs, int width, int height)
n_monitors++)
;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (double)width / (double)height, 0.001, 1000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -2);
glShadeModel(GL_SMOOTH);
return true;
return current_mode->configure(gs, width, height);
}
static bool update (GnomeScreensaver & gs)
{
return true;
return current_mode->update(gs);
}
int main (int argc, char *argv[])
{
GnomeScreensaver gs(&argc, &argv, configure, expose, update, 12);
Mode *modes[] = {
new Spin()
};
current_mode = modes[0];
GnomeScreensaver gs(&argc, &argv, configure, expose, update, 12);
gs.mainloop();
return 0;

37
modes/Spin.cc Normal file
View File

@ -0,0 +1,37 @@
#include <GL/gl.h>
#include <GL/glu.h>
#include "Spin.h"
bool Spin::expose (GnomeScreensaver & gs)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(gs.getTicks() / 1000.0 * 360.0 / 4.0, 0, 1, 0);
m_logobox.draw();
glPopMatrix();
return true;
}
bool Spin::configure (GnomeScreensaver & gs, int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (double)width/(double)height, 0.01, 1000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0, 0, 0, 0, 0, 4, 0, 1, 0);
return true;
}
bool Spin::update (GnomeScreensaver & gs)
{
return true;
}

21
modes/Spin.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef SPIN_H
#define SPIN_H
#include "LogoBox.h"
#include "Mode.h"
#include "GnomeScreensaver.h"
class Spin : public Mode
{
public:
bool expose (GnomeScreensaver & gs);
bool configure (GnomeScreensaver & gs, int width,
int height);
bool update (GnomeScreensaver & gs);
protected:
LogoBox m_logobox;
};
#endif /* SPIN_H */