better mouse control, higher res
This commit is contained in:
parent
b90dd89e2e
commit
f830812964
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "planet/Planet.h"
|
#include "planet/Planet.h"
|
||||||
|
|
||||||
Application::Application() : m_width(1080), m_height(720)
|
Application::Application() : m_width(1920), m_height(1080), m_lock(true)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -116,12 +116,13 @@ void Application::handleEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 mousepos = Input::getInstance().getMouseCoords();
|
glm::vec2 mousepos = Input::getInstance().getMouseCoords();
|
||||||
// Force mouse to the center of the screen
|
if (m_lock || Input::getInstance().isKeyDown(SDL_BUTTON_RIGHT)) {
|
||||||
SDL_SetWindowGrab(m_window, SDL_TRUE);
|
// Force mouse to the center of the screen
|
||||||
SDL_WarpMouseInWindow(m_window, m_width/2, m_height/2);
|
SDL_WarpMouseInWindow(m_window, m_width/2, m_height/2);
|
||||||
|
|
||||||
// Handle Camera Movement
|
// Handle Camera Movement
|
||||||
m_camera->processMouseMovement(-(m_width/2 - mousepos.x), m_height/2 - mousepos.y, GL_TRUE);
|
m_camera->processMouseMovement(-(m_width/2 - mousepos.x), m_height/2 - mousepos.y, GL_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
// Handle Camera Movement Keys
|
// Handle Camera Movement Keys
|
||||||
if(Input::getInstance().isKeyDown(SDLK_w))
|
if(Input::getInstance().isKeyDown(SDLK_w))
|
||||||
|
@ -148,8 +149,16 @@ void Application::handleEvents()
|
||||||
m_wireframe = !m_wireframe;
|
m_wireframe = !m_wireframe;
|
||||||
|
|
||||||
// Exit game on Esc
|
// Exit game on Esc
|
||||||
if(Input::getInstance().isKeyPressed(SDLK_ESCAPE))
|
if(Input::getInstance().isKeyPressed(SDLK_ESCAPE)) {
|
||||||
exit();
|
m_lock = !m_lock;
|
||||||
|
if (m_lock) {
|
||||||
|
SDL_SetWindowGrab(m_window, SDL_TRUE);
|
||||||
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
|
} else {
|
||||||
|
SDL_SetWindowGrab(m_window, SDL_FALSE);
|
||||||
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ class Application : public Singleton<Application>
|
||||||
|
|
||||||
bool m_run;
|
bool m_run;
|
||||||
bool m_wireframe;
|
bool m_wireframe;
|
||||||
|
bool m_lock;
|
||||||
|
|
||||||
void handleEvents();
|
void handleEvents();
|
||||||
void run();
|
void run();
|
||||||
|
|
Loading…
Reference in New Issue