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

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.
 

Detailed Description

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.

Function Documentation

◆ mouseButton()

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

Handles mouse button events to toggle camera control.

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 to adjust camera orientation.

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 = 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.

◆ cameraAngleY

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.

◆ lastMouseX

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.

◆ lastMouseY

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.

◆ leftButtonPressed

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.