Solar System OpenGL v1.0.0
|
Implements mouse input handling for camera control. More...
#include "mouse_handler.h"
Go to the source code of this file.
Functions | |
void | mouseMotion (int x, int y) |
Handles mouse motion events to adjust camera orientation. | |
void | mouseButton (int button, int state, int x, int y) |
Handles mouse button events to toggle camera control. | |
Variables | |
float | cameraAngleX = 0.0 |
Camera angle around the X-axis. | |
float | cameraAngleY = 0.0 |
Camera angle around the Y-axis. | |
int | lastMouseX = 0 |
X-coordinate of the last mouse position. | |
int | lastMouseY = 0 |
Y-coordinate of the last mouse position. | |
bool | leftButtonPressed = false |
State of the left mouse button. | |
Implements mouse input handling for camera control.
This file provides the implementation of functions for handling mouse input, including mouse motion and button events, to control the camera's position and orientation in the application.
void mouseButton | ( | int | button, |
int | state, | ||
int | x, | ||
int | y ) |
Handles mouse button events to toggle camera control.
Handles mouse button events.
button | The mouse button that was pressed or released. |
state | The state of the mouse button (GLUT_DOWN or GLUT_UP). |
x | The X-coordinate of the mouse cursor. |
y | The Y-coordinate of the mouse cursor. |
This function is called when a mouse button is pressed or released. It updates the state of the left mouse button and records the cursor position when the button is pressed.
void mouseMotion | ( | int | x, |
int | y ) |
Handles mouse motion events to adjust camera orientation.
Handles mouse motion events.
x | The X-coordinate of the mouse cursor. |
y | The Y-coordinate of the mouse cursor. |
This function is called when the mouse is moved. If the left mouse button is pressed, it updates the camera's orientation based on the cursor's position. The camera angles are clamped to prevent excessive rotation.
float cameraAngleX = 0.0 |
Camera angle around the X-axis.
This variable represents the rotation angle of the camera around the X-axis, affecting the vertical view direction.
This external variable represents the rotation angle of the camera around the X-axis, affecting the vertical view direction.
float cameraAngleY = 0.0 |
Camera angle around the Y-axis.
This variable represents the rotation angle of the camera around the Y-axis, affecting the horizontal view direction.
This external variable represents the rotation angle of the camera around the Y-axis, affecting the horizontal view direction.
int lastMouseX = 0 |
X-coordinate of the last mouse position.
This variable stores the X-coordinate of the mouse cursor during the last mouse event, used for calculating movement delta.
This external variable stores the X-coordinate of the mouse cursor during the last mouse event, used for calculating movement delta.
int lastMouseY = 0 |
Y-coordinate of the last mouse position.
This variable stores the Y-coordinate of the mouse cursor during the last mouse event, used for calculating movement delta.
This external variable stores the Y-coordinate of the mouse cursor during the last mouse event, used for calculating movement delta.
bool leftButtonPressed = false |
State of the left mouse button.
This boolean variable indicates whether the left mouse button is currently pressed, affecting camera control behavior.
This external boolean variable indicates whether the left mouse button is currently pressed, affecting camera control behavior.