Skip to content

Camera

Abstract base class for camera types.

This class is not intended to be used directly. Use PerspectiveCamera or OrthographicCamera unless you are defining your own camera type, in which case it should inherit from this class.

INFO

Derives from Node and inherits all public properties and methods.

Properties

projection_matrix Matrix4

cpp
Matrix4 projection_matrix { Matrix4::Identity() }

Projection matrix that maps camera-space coordinates to clip space.

view_matrix Matrix4

cpp
Matrix4 view_matrix { Matrix4::Identity() }

View matrix that maps world space to camera space.

Functions

Forward() Vector3

cpp
Vector3 vglx::Camera::Forward()

Camera forward axis in world space.

GetFrustum() Frustum

cpp
Frustum vglx::Camera::GetFrustum()

Computes a Frustum from the combined projection and view matrices. Useful for applying frustum culling to renderable nodes.

GetNodeType() Node::Type virtual

cpp
Node::Type vglx::Camera::GetNodeType() const override

Identifies this node as a camera. Always returns Node::Type::Camera, allowing runtime checks to distinguish camera nodes from other node types.

LookAt() void virtual

cpp
void vglx::Camera::LookAt(const Vector3 &target) override
ParameterDescription
targetWorld-space position for the camera to look at.

Overrides Node::LookAt to orient the camera toward a world-space target. Accounts for the camera’s -Z viewing direction so the camera faces the given point.

Resize() void pure virtual

cpp
virtual void vglx::Camera::Resize(int width, int height)=0
ParameterDescription
widthViewport width in pixels.
heightViewport height in pixels.

Updates projection_matrix to reflect the current viewport size. Must be implemented by derived cameras to apply the appropriate projection logic.

Right() Vector3

cpp
Vector3 vglx::Camera::Right()

Camera right axis in world space.

cpp
Vector3 vglx::Camera::Up()

Camera up axis in world space.

UpdateViewMatrix() void

cpp
void vglx::Camera::UpdateViewMatrix()

Sets view_matrix to the inverse of the camera's world transform. Called internally by the renderer before rendering a frame; manual calls are rarely necessary.

Released under the MIT License.