Skip to content

OrthographicCamera ​

Represents a camera that uses orthographic projection.

In this projection mode an object's size in the rendered image stays constant regardless of its distance from the camera. This can be useful for rendering 2D scenes and UI elements, amongst other things.

Although multiple cameras can be added to the scene graph and inherit transformations from their parent objects, only one camera is rendered at a time, the one passed to Renderer::Render. Construct it directly and pass it into the render call each frame.

cpp
auto camera = vglx::OrthographicCamera::Create({
  .left = 0.0f,
  .right = 1280.0f,
  .top = 0.0f,
  .bottom = 720.0f,
  .near = 0.1f,
  .far = 100.0f
});

renderer.Render(scene.get(), camera.get());

INFO

Derives from Camera and inherits all public properties and methods.

Construction ​

Constructors ​


OrthographicCamera() ​

Constructs an orthographic camera.

cpp
OrthographicCamera::OrthographicCamera(const Parameters& params);
ParameterDescription
paramsInitialization parameters for constructing the camera.

Factories preferred ​


OrthographicCamera::Create() std::unique_ptr<OrthographicCamera> ​

Creates an instance of OrthographicCamera with default parameters.

cpp
static std::unique_ptr<OrthographicCamera> OrthographicCamera::Create();

OrthographicCamera::Create() std::unique_ptr<OrthographicCamera> ​

Creates an instance of OrthographicCamera.

cpp
static std::unique_ptr<OrthographicCamera> OrthographicCamera::Create(const Parameters& params);
ParameterDescription
paramsInitialization parameters for constructing the camera.

Types ​

OrthographicCamera::ResizePolicy enum ​

Defines how the orthographic projection should adapt on window resize.

ValueDescription
PixelSpaceProjection matches framebuffer dimensions, preserving axis orientation.
FixedVerticalVertical extent remains constant, horizontal adjusted.
FixedHorizontalHorizontal extent remains constant, vertical adjusted.

OrthographicCamera::Parameters struct ​

Parameters for constructing an OrthographicCamera object.

ParameterDescription
left floatLeft clipping plane.
right floatRight clipping plane.
top floatTop clipping plane.
bottom floatBottom clipping plane.
near floatNear clipping plane.
far floatFar clipping plane.

Properties ​

resize_policy ResizePolicy ​

The current resize policy for this camera.

cpp
ResizePolicy resize_policy {ResizePolicy::PixelSpace};

Functions ​

SetLens() void ​

Configures orthographic projection parameters.

Replaces the camera's clipping planes and rebuilds the projection transform accordingly.

cpp
void OrthographicCamera::SetLens(const Parameters& params);
ParameterDescription
paramsProjection parameters defining the new clipping planes.

Released under the MIT License.