Compare commits
2 Commits
master
...
pedestal-m
Author | SHA1 | Date | |
---|---|---|---|
|
a324dc7d6e | ||
|
122952f13c |
98
modes/Pedestal.cc
Normal file
98
modes/Pedestal.cc
Normal file
@ -0,0 +1,98 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
#include "Pedestal.h"
|
||||
#include "glslUtil/glslUtil.h"
|
||||
|
||||
#define N_PEDESTAL_LEVELS 4
|
||||
#define TOP_LEVEL_SIZE 4
|
||||
#define LEVEL_INC_SIZE 1.5
|
||||
#define LEVEL_HEIGHT 1
|
||||
|
||||
static const GLfloat ped_normals[][3] = {
|
||||
{1, 0, 0},
|
||||
{0, 1, 0},
|
||||
{-1, 0, 0},
|
||||
{0, -1, 0},
|
||||
{0, 0, 1}
|
||||
};
|
||||
|
||||
Pedestal::Pedestal()
|
||||
{
|
||||
m_last_ticks = 0;
|
||||
srand(time(NULL) + getpid());
|
||||
}
|
||||
|
||||
Pedestal::~Pedestal()
|
||||
{
|
||||
}
|
||||
|
||||
bool Pedestal::expose (GnomeScreensaver & gs)
|
||||
{
|
||||
if (m_last_ticks == 0)
|
||||
{
|
||||
m_last_ticks = gs.getTicks();
|
||||
m_start_ticks = m_last_ticks;
|
||||
}
|
||||
uint64_t ticks = gs.getTicks();
|
||||
int elapsed = ticks - m_last_ticks;
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef((ticks - m_start_ticks) * 0.1, 0, 0, 1);
|
||||
|
||||
glRotatef(90.0, 1, 0, 0);
|
||||
m_logobox.draw();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
m_last_ticks = ticks;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Pedestal::configure (GnomeScreensaver & gs)
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(60.0, gs.getAspectRatio() / gs.getNumMonitors(),
|
||||
0.01, 1000.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt(0, -18, 4, 0, 0, 0, 0, 0, 1);
|
||||
|
||||
glViewport(0, 0, gs.getWidth(), gs.getHeight());
|
||||
|
||||
typedef struct {
|
||||
struct {
|
||||
GLfloat pos[3];
|
||||
GLfloat normal[3];
|
||||
} verts[8];
|
||||
} ped_vertex_data_t;
|
||||
ped_vertex_data_t * vdata = new ped_vertex_data_t[N_PEDESTAL_LEVELS];
|
||||
m_ped_vbo_id = guMakeBuffer(GL_ARRAY_BUFFER, GL_STATIC_DRAW,
|
||||
vdata, N_PEDESTAL_LEVELS * sizeof(vdata[0]));
|
||||
for (int i = 0; i < N_PEDESTAL_LEVELS; i++)
|
||||
{
|
||||
float z = i * LEVEL_HEIGHT;
|
||||
float r = TOP_LEVEL_SIZE / 2.0
|
||||
+ LEVEL_INC_SIZE * (N_PEDESTAL_LEVELS - 1 - i);
|
||||
}
|
||||
delete[] vdata;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Pedestal::update (GnomeScreensaver & gs)
|
||||
{
|
||||
return true;
|
||||
}
|
25
modes/Pedestal.h
Normal file
25
modes/Pedestal.h
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
#ifndef PEDESTAL_H
|
||||
#define PEDESTAL_H
|
||||
|
||||
#include "LogoBox.h"
|
||||
#include "Mode.h"
|
||||
#include "GnomeScreensaver.h"
|
||||
|
||||
class Pedestal : public Mode
|
||||
{
|
||||
public:
|
||||
Pedestal();
|
||||
~Pedestal();
|
||||
bool expose (GnomeScreensaver & gs);
|
||||
bool configure (GnomeScreensaver & gs);
|
||||
bool update (GnomeScreensaver & gs);
|
||||
protected:
|
||||
LogoBox m_logobox;
|
||||
uint64_t m_last_ticks;
|
||||
uint64_t m_start_ticks;
|
||||
GLint m_ped_vbo_id;
|
||||
};
|
||||
|
||||
#endif /* PEDESTAL_H */
|
||||
|
@ -35,8 +35,9 @@ static Mode *getMode(GnomeScreensaver & gs)
|
||||
#if 0
|
||||
return new Starfield(gs);
|
||||
return new Spin();
|
||||
#endif
|
||||
return new Tunnel();
|
||||
#endif
|
||||
return new Pedestal();
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
|
Loading…
x
Reference in New Issue
Block a user