dwss/dwss.cc
2010-11-24 16:30:14 -05:00

74 lines
1.4 KiB
C++

#include <math.h>
#include <stdlib.h>
#include <sysexits.h>
#include <time.h>
#include <sys/time.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "GnomeScreensaver.h"
#include "modes/modes.h"
using namespace std;
#define MAX_ASPECT (16.0/9.0*1.02)
static int n_monitors = 1;
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;
}
static bool configure (GnomeScreensaver & gs, int width, int height)
{
for (n_monitors = 1;
(double)width/(double)n_monitors/(double)height > MAX_ASPECT;
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;
}
static bool update (GnomeScreensaver & gs)
{
return true;
}
int main (int argc, char *argv[])
{
GnomeScreensaver gs(&argc, &argv, configure, expose, update, 12);
gs.mainloop();
return 0;
}