Camera

High-level camera utilities.

Overview

Typical use cases:

  • Handling 2D camera view and projection matrices

Header

<RaeptorCogs/Camera.hpp>

Metadata

Author

Estorc

Version

v1.0

Copyright

Copyright (c) 2025 Estorc MIT License.

Enums

Enumerations

Enum

Description

RaeptorCogs::CameraFlags

Camera flags enumeration.

enum class RaeptorCogs::CameraFlags : uint32_t

Camera flags enumeration.

Defines flags for camera state management.

Values:

enumerator NONE

No flags set.

enumerator NEEDS_REBUILD_VIEW_MATRIX

Indicates the view matrix needs to be rebuilt.

enumerator NEEDS_REBUILD_PROJECTION_MATRIX

Indicates the projection matrix needs to be rebuilt.

Classes

Classes

Class

Description

RaeptorCogs::Camera

Base Camera class.

RaeptorCogs::Camera2D

2D Camera class.

class Camera

Base Camera class.

Provides an interface for 2D and 3D camera implementations.

Subclassed by RaeptorCogs::Camera2D

Public Functions

virtual ~Camera() = default

Virtual destructor for Camera.

virtual glm::mat4 getViewMatrix() = 0

Get the view matrix of the camera.

virtual glm::mat4 getProjectionMatrix() = 0

Get the projection matrix of the camera.

Protected Attributes

glm::mat4 viewMatrix = glm::mat4(1.0f)

View matrix of the camera.

glm::mat4 projectionMatrix = glm::mat4(1.0f)

Projection matrix of the camera.

CameraFlags flags = CameraFlags::NEEDS_REBUILD_VIEW_MATRIX | CameraFlags::NEEDS_REBUILD_PROJECTION_MATRIX

Flags indicating the state of the camera.

class Camera2D : public RaeptorCogs::Camera, public RaeptorCogs::Component2D

2D Camera class.

Implements a simple 2D camera with position and zoom.

Public Functions

Camera2D()

Constructor for Camera2D.

~Camera2D()

Destructor for Camera2D.

virtual glm::mat4 getViewMatrix() override

Get the view matrix of the camera.

virtual glm::mat4 getProjectionMatrix() override

Get the projection matrix of the camera.

void setPosition(const glm::vec2 &pos)

Set the position of the camera.

void setZoom(float z)

Set the zoom level of the camera.

float getPositionX() const

Get the X position of the camera.

float getPositionY() const

Get the Y position of the camera.

glm::vec2 getPosition() const

Get the position of the camera as a vector.

float getZoom() const

Get the zoom level of the camera.

virtual void update(GAPI::Common::RenderPipeline &pipeline) override

Update the camera component.

Private Functions

void rebuildViewMatrix()

Rebuild the view matrix based on position and zoom.

void rebuildProjectionMatrix()

Rebuild the projection matrix based on zoom.

Private Members

glm::vec2 position = glm::vec2(0.0f, 0.0f)

Position of the camera in 2D space.

float zoom = 1.0f

Zoom level of the camera.