35 float left = -halfWidth;
36 float right = halfWidth;
37 float bottom = -halfHeight;
38 float top = halfHeight;
42 return glm::ortho(left, right, bottom, top, near, far);
62 const glm::vec2 startPos = glm::vec2(0.0f, 0.0f);
63 const float startRot = 0.0f;
64 const float startZoom = 1.0f;
94 glm::mat4 result(1.0f);
96 result[0][0] = 2.0f / (right - left);
97 result[1][1] = 2.0f / (bottom - top);
98 result[2][2] = 1.0f / (farPlane - nearPlane);
100 result[3][0] = -(right + left) / (right - left);
101 result[3][1] = -(bottom + top) / (bottom - top);
102 result[3][2] = -nearPlane / (farPlane - nearPlane);
glm::mat4 ComputeOrthographicMatrix(float left, float right, float top, float bottom, float nearPlane, float farPlane) const
glm::mat4 GetProjectionMatrix() const
Returns the current orthographic projection matrix.
void SetRotation(float angleDegrees)
Sets the camera rotation angle in degrees (counterclockwise, around Z).
void SetPosition(const glm::vec2 &position)
Sets the camera position.
glm::vec2 GetPosition() const
Gets the camera position.
std::unique_ptr< SceneComponent2D > mSceneComponent
void Reset()
Resets the camera to the default view (origin, zero rotation, unit zoom).
void SetViewportSize(float width, float height)
Sets the viewport dimensions used to compute the projection matrix.
void SetZoom(float zoom)
Sets the camera zoom (uniform scale).
const glm::mat4 & GetWorldView() const
Gets the world-view (model) matrix for the camera.
Camera2D(IApplication &app)
Constructs a 2D camera at the origin, with no rotation and unit zoom.
float GetRotation() const
Gets the camera rotation angle in degrees.
virtual void Update(float deltaTime)
Updates the camera logic (no-op for now).
float GetZoom() const
Gets the current zoom factor.
virtual void Initialize()
Initializes the camera (calls Reset()).
Defines a generic application interface for rendering-based programs.
Represents a 2D transformable scene component with position, rotation, and scale.