cameraRight = glm::normalize(glm::cross(cameraFront, WorldUp)); // normalize the vectors, because their length gets closer to 0 the more you look up or down which results in slower movement.
float xoffset = (xpos - lastX) * mouseSensitivity; float yoffset = (lastY - ypos) * mouseSensitivity; // reversed since y-coordinates go from bottom to top
lastX = xpos; lastY = ypos;
yaw += xoffset; pitch += yoffset;
if (pitch > 89.0f) pitch = 89.0f; if (pitch < -89.0f) pitch = -89.0f;
glm::vec3 front; front.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch)); front.y = sin(glm::radians(pitch)); front.z = sin(glm::radians(yaw)) * cos(glm::radians(pitch)); cameraFront = glm::normalize(front); // also re-calculate the Right and Up vector glm::vec3 cameraRight = glm::normalize(glm::cross(cameraFront, glm::vec3(0, 1, 0))); // normalize the vectors, because their length gets closer to 0 the more you look up or down which results in slower movement. cameraUp = glm::normalize(glm::cross(cameraRight, cameraFront)); }
voidmouse_button_Callback(GLFWwindow *window, int key, int action, int mode) { if (key == GLFW_MOUSE_BUTTON_RIGHT) { if (action == GLFW_PRESS) { ClickDown = GL_TRUE; } elseif (action == GLFW_RELEASE) { ClickDown = GL_FALSE; } } }