Camera class
#include <include/engine/graphics/camera.h>
Simple 2D Camera that manages the Orthographic projection.
It manages three matrices internally:
- Projection Matrix: Maps world coordinates (e.g., 0 to 1920) to GPU space (-1 to 1). This defines your "Resolution" or "Aspect Ratio".
- View Matrix: Represents the Camera's position and rotation in the world. Moving the camera Right (+X) actually moves the View Matrix Left (-X).
- ViewProjection Matrix: The combination (Proj * View). This is what we send to the Shader to transform every vertex in one go.
Constructors, destructors, conversion operators
- Camera(float left, float right, float bottom, float top)
- Create a camera by defining the view boundaries.
Public functions
- void set_projection(float left, float right, float bottom, float top)
- Updates the boundaries (useful for window resizing).
- void set_position(const glm::vec3& position)
- Moves the camera in world space.
- auto position() const -> const glm::vec3&
- Gets the current position of the camera.
- auto view_projection_matrix() const -> const glm::mat4&
- Gets the cached view-projection matrix.
Function documentation
engine:: graphics:: Camera:: Camera(float left,
float right,
float bottom,
float top)
Create a camera by defining the view boundaries.
| Parameters | |
|---|---|
| left | Left boundary. |
| right | Right boundary. |
| bottom | Bottom boundary. |
| top | Top boundary. |
Note: Flipping 'bottom' and 'top' determines if (0,0) is Top-Left or Bottom-Left.
void engine:: graphics:: Camera:: set_projection(float left,
float right,
float bottom,
float top)
Updates the boundaries (useful for window resizing).
| Parameters | |
|---|---|
| left | Left boundary. |
| right | Right boundary. |
| bottom | Bottom boundary. |
| top | Top boundary. |
void engine:: graphics:: Camera:: set_position(const glm::vec3& position)
Moves the camera in world space.
| Parameters | |
|---|---|
| position | The new position. |
const glm::vec3& engine:: graphics:: Camera:: position() const
Gets the current position of the camera.
| Returns | The position. |
|---|
const glm::mat4& engine:: graphics:: Camera:: view_projection_matrix() const
Gets the cached view-projection matrix.
| Returns | The matrix. |
|---|