dwscr/ss/PlainSpin.cc
josh 68d41e9c63 moved files to trunk directory
git-svn-id: svn://anubis/dwscr/trunk@83 5bef9df8-b654-44bb-925b-0ff18baa8f8c
2008-09-22 17:27:40 +00:00

47 lines
1.3 KiB
C++

/* Author: Josh Holtrop
* DornerWorks screensaver
* This module implements a very simple screensaver mode.
* It just creates a DW logo and then continuously spins around it.
*/
#include <GL/gl.h>
#include <GL/glu.h>
#include "PlainSpin.h"
#include <iostream>
using namespace std;
/* construct screensaver mode and do some basic OpenGL setup */
PlainSpin::PlainSpin(SSMain * _SSMain) : SSMode(_SSMain)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0,
(double)m_SSMain->getWidth()
/ (double)m_SSMain->getHeight()
/ (double)m_SSMain->getNumMonitors(),
0.01,
1000.01);
glMatrixMode(GL_MODELVIEW);
}
/* called every time this screensaver mode should redraw the screen */
void PlainSpin::update()
{
SSMode::update();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
int numMonitors = m_SSMain->getNumMonitors();
int width = m_SSMain->getWidth();
int height = m_SSMain->getHeight();
for (int i = 0; i < numMonitors; i++)
{
glViewport(i*width/numMonitors, 0, width/numMonitors, height);
glLoadIdentity();
gluLookAt(0, 0, 12, 0, 0, 0, 0, 1, 0);
glRotatef(m_elapsed/33.0f, 0, 1, 0);
m_logoBox.draw();
}
SDL_GL_SwapBuffers();
}