GLFW: input & timeGLFW 1.0
glfwGetMouseButton
Asks whether a mouse button is held down right now.
Signature
int glfwGetMouseButton(GLFWwindow* window, int button);
How it works
The mouse version of glfwGetKey: good for "while the right button is held, rotate the camera" or dragging. For single clicks, glfwSetMouseButtonCallback is the better tool.
Parameters
windowGLFWwindow*
The window to ask about.
Return value
GLFW_PRESS or GLFW_RELEASE.
Errors
When the call is invalid it does nothing and sets an error, which glGetError returns:
- GLFW_NOT_INITIALIZED
- Called before glfwInit or after glfwTerminate.
- GLFW_INVALID_ENUM
- A hint, mode, key or button argument is not a valid GLFW constant.
Example
example.cpp
1if (glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS)
2 orbitCamera(mouseDx, mouseDy);