Modified cursor grab behaviour
Cursor is now trapped inside the window and will jump from one side to another when nearing the border. The cursor is now hidden to reinforce the illusion. Warping the cursor to the center did not work well at all on my Windows machine (Might be because it is much more powerful than my laptop) so I had to find another way.
This commit is contained in:
parent
89a627695c
commit
70f76d8030
3 changed files with 43 additions and 24 deletions
19
src/main.cpp
19
src/main.cpp
|
@ -37,30 +37,30 @@ void manage_inputs()
|
|||
if (InputStatus::is_special_key_pressed(GLUT_KEY_RIGHT))
|
||||
{
|
||||
timer_ticks += 5;
|
||||
camera.translate({0,0,1});
|
||||
camera.translate({0,0,0.1});
|
||||
}
|
||||
if (InputStatus::is_special_key_pressed(GLUT_KEY_LEFT))
|
||||
{
|
||||
timer_ticks -= 5;
|
||||
camera.translate({0,0,-1});
|
||||
camera.translate({0,0,-0.1});
|
||||
}
|
||||
if (InputStatus::is_key_pressed(' '))
|
||||
{
|
||||
camera.translate({0,1,0});
|
||||
camera.translate({0,0.1,0});
|
||||
}
|
||||
if (InputStatus::is_special_key_pressed(GLUT_KEY_PAGE_DOWN))
|
||||
{
|
||||
camera.translate({0,-1,0});
|
||||
camera.translate({0,-0.1,0});
|
||||
}
|
||||
|
||||
if (InputStatus::is_special_key_pressed(GLUT_KEY_UP))
|
||||
{
|
||||
camera.translate({1,0,0});
|
||||
camera.translate({0.1,0,0});
|
||||
}
|
||||
|
||||
if (InputStatus::is_special_key_pressed(GLUT_KEY_DOWN))
|
||||
{
|
||||
camera.translate({-1,0,0});
|
||||
camera.translate({-0.1,0,0});
|
||||
}
|
||||
|
||||
// Get mouse delta since last frame
|
||||
|
@ -109,8 +109,8 @@ void reshape(int new_x, int new_y)
|
|||
glViewport(0,0,new_x,new_y);
|
||||
|
||||
aspect_ratio = (double)new_x/new_y;
|
||||
InputStatus::window_center.x = new_x / 2;
|
||||
InputStatus::window_center.y = new_y / 2;
|
||||
InputStatus::window_size.x = new_x;
|
||||
InputStatus::window_size.y = new_y;
|
||||
}
|
||||
|
||||
void update_angle(int value)
|
||||
|
@ -126,12 +126,11 @@ int main(int argc, char** argv)
|
|||
glutInitDisplayMode(GLUT_RGB| GLUT_DEPTH | GLUT_DOUBLE);
|
||||
glutCreateWindow("OpenGL custom engine tests");
|
||||
glutIgnoreKeyRepeat(true);
|
||||
glutSetCursor(GLUT_CURSOR_NONE);
|
||||
|
||||
// Init OpenGL
|
||||
glClearColor(0,0,0,1);
|
||||
glClearDepth(1.0);
|
||||
// glEnable(GL_LIGHTING);
|
||||
// glEnable(GL_LIGHT0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
// Setup OPenGL to use textures
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue