Click-to-camera!

This commit is contained in:
2014-03-11 16:11:12 +01:00
parent f027773af8
commit 43ab2473ec
3 changed files with 52 additions and 36 deletions
+16 -3
View File
@@ -21,9 +21,22 @@ void Systems::InputSystem::Update(double dt)
glfwGetCursorPos(m_Renderer->GetWindow(), &xpos, &ypos);
m_CurrentMouseDeltaX = xpos - m_LastMouseX;
m_CurrentMouseDeltaY = ypos - m_LastMouseY;
m_LastMouseX = m_Renderer->WIDTH / 2.f; // xpos;
m_LastMouseY = m_Renderer->HEIGHT / 2.f; // ypos;
glfwSetCursorPos(m_Renderer->GetWindow(), m_LastMouseX, m_LastMouseY);
m_LastMouseX = xpos;
m_LastMouseY = ypos;
// Lock mouse while holding LMB
if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT]) {
m_LastMouseX = m_Renderer->WIDTH / 2.f; // xpos;
m_LastMouseY = m_Renderer->HEIGHT / 2.f; // ypos;
glfwSetCursorPos(m_Renderer->GetWindow(), m_LastMouseX, m_LastMouseY);
}
// Hide/show cursor with LMB
if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT] && !m_LastMouseState[GLFW_MOUSE_BUTTON_LEFT]) {
glfwSetInputMode(m_Renderer->GetWindow(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
}
if (!m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT] && m_LastMouseState[GLFW_MOUSE_BUTTON_LEFT]) {
glfwSetInputMode(m_Renderer->GetWindow(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
}
#ifdef DEBUG
// Wireframe