src/main.cpp
// glfw: whenever the mouse moves, this callback is called
// -------------------------------------------------------
whenever the mouse moves, this callback is called
whenever the mouse moves this callback is called
void mouse_callback(GLFWwindow* window, double xpos, double ypos) {
    auto& state = *static_cast<engine::State*>(glfwGetWindowUserPointer(window));
    auto camera = state.getCamera();
    auto mouse = state.getMouseMovement();
    auto xPos = static_cast<float>(xpos);
    auto yPos = static_cast<float>(ypos);
    if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED) {
        if (mouse->firstMouse) {
            mouse->lastX = xPos;
            mouse->lastY = yPos;
            mouse->firstMouse = false;
        }
        float xOffset = xPos - mouse->lastX;
        float yOffset = mouse->lastY - yPos; 
        mouse->lastX = xPos;
        mouse->lastY = yPos;
        camera->processMouseMovement(xOffset, yOffset);
    }
}
void mouse_callback ( GLFWwindow * window , double xpos , double ypos ) { auto & state = * static_cast < engine :: State * > ( glfwGetWindowUserPointer ( window ) ) ; auto camera = state . getCamera ( ) ; auto mouse = state . getMouseMovement ( ) ; auto xPos = static_cast < float > ( xpos ) ; auto yPos = static_cast < float > ( ypos ) ; if ( glfwGetInputMode ( window , GLFW_CURSOR ) == GLFW_CURSOR_DISABLED ) { if ( mouse -> firstMouse ) { mouse -> lastX = xPos ; mouse -> lastY = yPos ; mouse -> firstMouse = false ; } float xOffset = xPos - mouse -> lastX ; float yOffset = mouse -> lastY - yPos ; mouse -> lastX = xPos ; mouse -> lastY = yPos ; camera -> processMouseMovement ( xOffset , yOffset ) ; } }
glfw: whenever the mouse moves, this callback is called
glfw : whenever the mouse moves this callback is called
// reversed since y-coordinates go from bottom to top