52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
|
|
/* Author: Josh Holtrop
|
|
* DornerWorks screensaver
|
|
* SSMode is base class that provides common functionality for
|
|
* screensaver modes. It should be extended by a screensaver
|
|
* mode implementing class.
|
|
*/
|
|
|
|
#include "SSMode.h"
|
|
|
|
SSMode::SSMode(SSMain * _SSMain)
|
|
: m_SSMain(_SSMain)
|
|
{
|
|
m_startTick = SDL_GetTicks();
|
|
}
|
|
|
|
SSMode::~SSMode()
|
|
{
|
|
}
|
|
|
|
/* update the number of elapsed milliseconds */
|
|
void SSMode::update()
|
|
{
|
|
Uint32 ticks = SDL_GetTicks();
|
|
m_elapsed = ticks - m_startTick;
|
|
}
|
|
|
|
/* push an OpenGL matrix onto the matrix stack for a given
|
|
* ODE body position and rotation */
|
|
void SSMode::pushTransform(const dReal pos[3], const dReal R[12])
|
|
{
|
|
GLfloat matrix[16];
|
|
matrix[0] = R[0];
|
|
matrix[1] = R[4];
|
|
matrix[2] = R[8];
|
|
matrix[3] = 0;
|
|
matrix[4] = R[1];
|
|
matrix[5] = R[5];
|
|
matrix[6] = R[9];
|
|
matrix[7] = 0;
|
|
matrix[8] = R[2];
|
|
matrix[9] = R[6];
|
|
matrix[10] = R[10];
|
|
matrix[11] = 0;
|
|
matrix[12] = pos[0];
|
|
matrix[13] = pos[1];
|
|
matrix[14] = pos[2];
|
|
matrix[15] = 1;
|
|
glPushMatrix();
|
|
glMultMatrixf(matrix);
|
|
}
|