Fixing cursor position staying the same introduced by GLFW 3.1.

This commit is contained in:
Faerbit 2015-03-12 15:44:21 +01:00
parent 1bf34b6751
commit 89874b8612

View File

@ -29,8 +29,8 @@ static void mouseCallback(GLFWwindow* window, int button, int action, int) {
app.startGame(); app.startGame();
} }
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) { if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) {
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
glfwSetCursorPos(window, app.getGraphics()->getWindowSize().x/2, app.getGraphics()->getWindowSize().y/2); glfwSetCursorPos(window, ((double)app.getGraphics()->getWindowSize().x)/2.0, ((double)app.getGraphics()->getWindowSize().y)/2.0);
app.setCameraLock(true); app.setCameraLock(true);
} }
} }
@ -42,7 +42,7 @@ static void scrollCallback(GLFWwindow* window, double xoffset, double yoffset) {
static void focusCallback(GLFWwindow* window, int focused) { static void focusCallback(GLFWwindow* window, int focused) {
if (focused) { if (focused) {
// Hide mouse cursor // Hide mouse cursor
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
app.setFocused(focused); app.setFocused(focused);
} }
else { else {
@ -173,7 +173,7 @@ int main( int argc, char *argv[] )
double xpos, ypos; double xpos, ypos;
glfwGetCursorPos(window, &xpos, &ypos); glfwGetCursorPos(window, &xpos, &ypos);
glfwSetCursorPos(window, app.getGraphics()->getWindowSize().x/2, app.getGraphics()->getWindowSize().y/2); glfwSetCursorPos(window, ((double)app.getGraphics()->getWindowSize().x)/2.0, ((double)app.getGraphics()->getWindowSize().y)/2.0);
app.getLevel()->update(now - lastUpdate, now - gameStart, app.getLevel()->update(now - lastUpdate, now - gameStart,
glm::vec2((float)ypos-app.getGraphics()->getWindowSize().y/2, glm::vec2((float)ypos-app.getGraphics()->getWindowSize().y/2,
(float)xpos-app.getGraphics()->getWindowSize().x/2), (float)xpos-app.getGraphics()->getWindowSize().x/2),