2011-10-19 01:10:15 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
2011-12-06 22:35:48 +01:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gtk/gtkgl.h>
|
|
|
|
#include <GL/glut.h>
|
2011-10-19 01:10:15 +02:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "input.h"
|
2011-10-30 23:55:53 +01:00
|
|
|
#include "display.h"
|
2011-10-19 01:10:15 +02:00
|
|
|
|
2011-10-31 00:25:07 +01:00
|
|
|
|
2011-10-19 01:10:15 +02:00
|
|
|
void moveCameraPosition(float direction) {
|
|
|
|
eyePos += direction;
|
|
|
|
if (eyePos > 360.0) eyePos = 0.0;
|
|
|
|
|
2011-10-20 20:28:00 +02:00
|
|
|
lookX = sin(eyePos * PI/180.0)*70.0;
|
|
|
|
lookZ = cos(eyePos * PI/180.0)*70.0;
|
2011-10-19 01:10:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void moveCameraAngle(float angle) {
|
|
|
|
eyeAngle += angle;
|
|
|
|
if (eyeAngle > 120) eyeAngle = 120;
|
|
|
|
if (eyeAngle < 0) eyeAngle = 0;
|
|
|
|
}
|
|
|
|
|
2011-10-30 23:55:53 +01:00
|
|
|
void mouse(int button, int state, int x, int y) {
|
|
|
|
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
|
2011-10-31 00:25:07 +01:00
|
|
|
int position, viewport[4];
|
2011-10-30 23:55:53 +01:00
|
|
|
GLubyte pixel[3];
|
|
|
|
|
|
|
|
displayPickingObjects();
|
|
|
|
|
|
|
|
glGetIntegerv(GL_VIEWPORT, viewport);
|
|
|
|
glReadPixels(x, viewport[3]-y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, (void*)pixel);
|
2011-10-31 00:25:07 +01:00
|
|
|
position = ((int)pixel[2]/8)-1; // Selected LED
|
|
|
|
|
|
|
|
printf("%d\n", position);
|
|
|
|
currentFrame[position] = currentFrame[position] == 0 ? 1 : 0;
|
|
|
|
printf("%d\n", currentFrame[position]);
|
|
|
|
|
2011-12-06 22:35:48 +01:00
|
|
|
// FIXME: Redraw the gl-container
|
|
|
|
//display();
|
2011-10-30 23:55:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|