I'm creating an OpenGL application in c++ using GLFW. Based on this tutorial i managed to create FPS like camera(WASD movement + pitch-yaw with mouse movement).
For camera mouse movement i'm using
glfwSetCursorPosCallback(window, mouse_callback);
void mouse_callback(GLFWwindow* window, double xpos, double ypos)
{
if (firstMouse)
{
lastX = xpos;
lastY = ypos;
firstMouse = false;
}
float xoffset = xpos - lastX;
float yoffset = lastY - ypos;
lastX = xpos;
lastY = ypos;
float sensitivity = 0.1f;
xoffset *= sensitivity;
yoffset *= sensitivity;
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);
}
This is working fine, but problem is that my application window is not full screen, so if i want to rotate my mouse cursor gets out of window and then it's hard to control camera.
Is it possible to do the same thing as glfwSetCursorPosCallback, but only if left click is pressed? I want the camera do the same thing as its doing now, but only if i pressed left click.