Solar System OpenGL v1.0.0
Loading...
Searching...
No Matches
mouse_handler.h File Reference

Handles mouse input for camera control. More...

#include <GL/glut.h>

Go to the source code of this file.

Functions

void mouseMotion (int x, int y)
 Handles mouse motion events.
 
void mouseButton (int button, int state, int x, int y)
 Handles mouse button events.
 

Variables

float cameraDistance
 Distance of the camera from the target.
 
float cameraAngleX
 Camera angle around the X-axis.
 
float cameraAngleY
 Camera angle around the Y-axis.
 
int lastMouseX
 X-coordinate of the last mouse position.
 
int lastMouseY
 Y-coordinate of the last mouse position.
 
bool leftButtonPressed
 State of the left mouse button.
 

Detailed Description

Handles mouse input for camera control.

This file declares functions and external variables used for handling mouse input to control the camera's position and orientation in the application.

Function Documentation

◆ mouseButton()

void mouseButton ( int button,
int state,
int x,
int y )

Handles mouse button events.

Parameters
buttonThe mouse button that was pressed or released.
stateThe state of the mouse button (GLUT_DOWN or GLUT_UP).
xThe X-coordinate of the mouse cursor.
yThe Y-coordinate of the mouse cursor.

This function is called when a mouse button is pressed or released, allowing updates to the camera's control state.

Handles mouse button events.

Parameters
buttonThe mouse button that was pressed or released.
stateThe state of the mouse button (GLUT_DOWN or GLUT_UP).
xThe X-coordinate of the mouse cursor.
yThe 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.

◆ mouseMotion()

void mouseMotion ( int x,
int y )

Handles mouse motion events.

Parameters
xThe X-coordinate of the mouse cursor.
yThe Y-coordinate of the mouse cursor.

This function is called when the mouse is moved, allowing updates to the camera's orientation based on the cursor's position.

Handles mouse motion events.

Parameters
xThe X-coordinate of the mouse cursor.
yThe 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.

Variable Documentation

◆ cameraAngleX

float cameraAngleX
extern

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.

◆ cameraAngleY

float cameraAngleY
extern

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.

◆ cameraDistance

float cameraDistance
extern

Distance of the camera from the target.

This variable represents the distance between the camera and the point it is observing, affecting the zoom level.

This external float variable represents the distance between the camera and the point it is observing, affecting the zoom level.

This external variable represents the distance between the camera and the point it is looking at, affecting the zoom level.

◆ lastMouseX

int lastMouseX
extern

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.

◆ lastMouseY

int lastMouseY
extern

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.

◆ leftButtonPressed

bool leftButtonPressed
extern

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.