replaced directions and rotations array with generic per-monitor info structure array
This commit is contained in:
parent
6136404999
commit
7d16486f8f
@ -16,10 +16,9 @@ static const float directions[][3] = {
|
||||
Spin::Spin()
|
||||
{
|
||||
m_num_monitors = 1;
|
||||
m_directions = new int[m_num_monitors];
|
||||
m_directions[0] = 1;
|
||||
m_rotations = new matrix_t[m_num_monitors];
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, &m_rotations[0][0]);
|
||||
m_monitor_info = new monitor_info_t[m_num_monitors];
|
||||
m_monitor_info[0].direction = 1;
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, &m_monitor_info[0].rotation[0]);
|
||||
m_last_switch_ticks = 0;
|
||||
m_last_ticks = 0;
|
||||
srand(time(NULL));
|
||||
@ -27,8 +26,7 @@ Spin::Spin()
|
||||
|
||||
Spin::~Spin()
|
||||
{
|
||||
delete[] m_directions;
|
||||
delete[] m_rotations;
|
||||
delete[] m_monitor_info;
|
||||
}
|
||||
|
||||
bool Spin::expose (GnomeScreensaver & gs)
|
||||
@ -39,10 +37,11 @@ bool Spin::expose (GnomeScreensaver & gs)
|
||||
{
|
||||
for (int i = 0; i < m_num_monitors; i++)
|
||||
{
|
||||
m_directions[i] = (int) (rand() / (double)RAND_MAX *
|
||||
m_monitor_info[i].direction = (int) (rand() / (double)RAND_MAX *
|
||||
sizeof(directions) / sizeof(directions[0]));
|
||||
if (m_directions[i] >= sizeof(directions) / sizeof(directions[0]))
|
||||
m_directions[i] = 0;
|
||||
if (m_monitor_info[i].direction
|
||||
>= sizeof(directions) / sizeof(directions[0]))
|
||||
m_monitor_info[i].direction = 0;
|
||||
}
|
||||
m_last_switch_ticks = gs.getTicks();
|
||||
}
|
||||
@ -54,14 +53,15 @@ bool Spin::expose (GnomeScreensaver & gs)
|
||||
{
|
||||
glViewport(width * monitor_num, 0, width, gs.getHeight());
|
||||
|
||||
glLoadMatrixf(&m_rotations[monitor_num][0]);
|
||||
glLoadMatrixf(&m_monitor_info[monitor_num].rotation[0]);
|
||||
|
||||
int direction = m_directions[monitor_num];
|
||||
int direction = m_monitor_info[monitor_num].direction;
|
||||
glRotatef((gs.getTicks() - m_last_ticks) / 1000.0 * 360.0 / 4.0,
|
||||
directions[direction][0],
|
||||
directions[direction][1],
|
||||
directions[direction][2]);
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, &m_rotations[monitor_num][0]);
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX,
|
||||
&m_monitor_info[monitor_num].rotation[0]);
|
||||
|
||||
m_logobox.draw();
|
||||
}
|
||||
@ -82,17 +82,16 @@ bool Spin::configure (GnomeScreensaver & gs)
|
||||
gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
|
||||
|
||||
m_num_monitors = gs.getNumMonitors();
|
||||
delete[] m_directions;
|
||||
delete[] m_rotations;
|
||||
m_directions = new int[m_num_monitors];
|
||||
m_rotations = new matrix_t[m_num_monitors];
|
||||
delete[] m_monitor_info;
|
||||
m_monitor_info = new monitor_info_t[m_num_monitors];
|
||||
for (int i = 0; i < m_num_monitors; i++)
|
||||
{
|
||||
m_directions[i] = (int) (rand() / (double)RAND_MAX *
|
||||
m_monitor_info[i].direction = (int) (rand() / (double)RAND_MAX *
|
||||
sizeof(directions) / sizeof(directions[0]));
|
||||
if (m_directions[i] >= sizeof(directions) / sizeof(directions[0]))
|
||||
m_directions[i] = 0;
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, &m_rotations[i][0]);
|
||||
if (m_monitor_info[i].direction
|
||||
>= sizeof(directions) / sizeof(directions[0]))
|
||||
m_monitor_info[i].direction = 0;
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, &m_monitor_info[i].rotation[0]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
10
modes/Spin.h
10
modes/Spin.h
@ -14,12 +14,16 @@ class Spin : public Mode
|
||||
bool expose (GnomeScreensaver & gs);
|
||||
bool configure (GnomeScreensaver & gs);
|
||||
bool update (GnomeScreensaver & gs);
|
||||
typedef float matrix_t[16];
|
||||
typedef struct monitor_info_s
|
||||
{
|
||||
int direction;
|
||||
float rotation[16];
|
||||
int switch_time;
|
||||
} monitor_info_t;
|
||||
protected:
|
||||
LogoBox m_logobox;
|
||||
int * m_directions;
|
||||
matrix_t * m_rotations;
|
||||
int m_num_monitors;
|
||||
monitor_info_t *m_monitor_info;
|
||||
unsigned int m_last_switch_ticks;
|
||||
unsigned int m_last_ticks;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user