First implementation of input control with KeyStateManager
To try to do: Manage edges
This commit is contained in:
parent
236fd2b8d6
commit
3639b48273
4 changed files with 149 additions and 2 deletions
27
src/main.cpp
27
src/main.cpp
|
@ -4,15 +4,38 @@
|
|||
#include "displayers.h"
|
||||
#include "DataHandling/Texture.h"
|
||||
#include "DataHandling/Model3D.h"
|
||||
|
||||
#include "KeyStateManager.h"
|
||||
|
||||
volatile unsigned long long int timer_ticks = 0;
|
||||
static Texture tree_texture;
|
||||
static Model3D raptor;
|
||||
static Texture raptor_texture;
|
||||
|
||||
void manage_inputs()
|
||||
{
|
||||
if (KeyStateManager::is_key_pressed(' '))
|
||||
{
|
||||
glClearColor(0.5,0,0,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
glClearColor(0,0,0,1);
|
||||
}
|
||||
|
||||
if (KeyStateManager::is_special_key_pressed(GLUT_KEY_RIGHT))
|
||||
{
|
||||
timer_ticks += 5;
|
||||
}
|
||||
if (KeyStateManager::is_special_key_pressed(GLUT_KEY_LEFT))
|
||||
{
|
||||
timer_ticks -= 5;
|
||||
}
|
||||
}
|
||||
|
||||
void display()
|
||||
{
|
||||
manage_inputs();
|
||||
|
||||
float angleY = 1*timer_ticks;
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
@ -54,6 +77,7 @@ int main(int argc, char** argv)
|
|||
// Generate window with GLUT
|
||||
glutInitDisplayMode(GLUT_RGB| GLUT_DEPTH | GLUT_DOUBLE);
|
||||
glutCreateWindow("Hello");
|
||||
glutIgnoreKeyRepeat(true);
|
||||
|
||||
// Init OpenGL
|
||||
glClearColor(0,0,0,1);
|
||||
|
@ -96,6 +120,7 @@ int main(int argc, char** argv)
|
|||
|
||||
glutIdleFunc(display);
|
||||
glutTimerFunc(50,update_angle,0);
|
||||
KeyStateManager::register_glut_callbacks();
|
||||
|
||||
// Enters main loop, managed by GLUT
|
||||
glutMainLoop();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue