From 49d091deebf8ea2c091a8570d3f5a6d226d1ebb8 Mon Sep 17 00:00:00 2001 From: josh Date: Thu, 13 Nov 2008 01:34:00 +0000 Subject: [PATCH] added LightBounce mode copied from PlainSpin git-svn-id: svn://anubis/dwscr/trunk@90 5bef9df8-b654-44bb-925b-0ff18baa8f8c --- ss/LightBounce.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++ ss/LightBounce.h | 22 ++++++++++++++++++++++ ss/Makefile | 1 + ss/SSMain.cc | 9 ++++++--- 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 ss/LightBounce.cc create mode 100644 ss/LightBounce.h diff --git a/ss/LightBounce.cc b/ss/LightBounce.cc new file mode 100644 index 0000000..0039d1b --- /dev/null +++ b/ss/LightBounce.cc @@ -0,0 +1,44 @@ + +/* Author: Josh Holtrop + * DornerWorks screensaver + */ + +#include +#include +#include "LightBounce.h" + +#include +using namespace std; + +/* construct screensaver mode and do some basic OpenGL setup */ +LightBounce::LightBounce(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 LightBounce::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(); +} diff --git a/ss/LightBounce.h b/ss/LightBounce.h new file mode 100644 index 0000000..8561fd1 --- /dev/null +++ b/ss/LightBounce.h @@ -0,0 +1,22 @@ + +/* Author: Josh Holtrop + * DornerWorks screensaver + */ + +#ifndef LIGHTBOUNCE_H +#define LIGHTBOUNCE_H + +#include "SSMain.h" +#include "SSMode.h" +#include "LogoBox.h" + +class LightBounce : public SSMode +{ +public: + LightBounce(SSMain * _SSMain); + void update(); +protected: + LogoBox m_logoBox; +}; + +#endif diff --git a/ss/Makefile b/ss/Makefile index 9755a2d..73138f5 100644 --- a/ss/Makefile +++ b/ss/Makefile @@ -3,6 +3,7 @@ OBJS := SSMain.o OBJS += SSMode.o OBJS += LogoBox.o OBJS += PlainSpin.o +OBJS += LightBounce.o ifndef WITHOUT_ODE OBJS += TumblingLogos.o OBJS += Towers.o diff --git a/ss/SSMain.cc b/ss/SSMain.cc index 9411fbe..8c58ac9 100644 --- a/ss/SSMain.cc +++ b/ss/SSMain.cc @@ -14,6 +14,7 @@ #include #include "SSMain.h" #include "PlainSpin.h" +#include "LightBounce.h" #ifndef WITHOUT_ODE #include "TumblingLogos.h" #include "Towers.h" @@ -124,9 +125,9 @@ SSMode * SSMain::startMode() { static int mode = 0; #ifndef WITHOUT_ODE - const int numModes = 3; + const int numModes = 4; #else - const int numModes = 1; + const int numModes = 2; #endif mode++; @@ -137,8 +138,10 @@ SSMode * SSMain::startMode() { case 0: return new PlainSpin(this); -#ifndef WITHOUT_ODE case 1: + return new LightBounce(this); +#ifndef WITHOUT_ODE + case 2: return new Towers(this); default: return new TumblingLogos(this);