OrthographicCamera
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 can be active at a time. The active camera is managed by the application’s runtime object:
class MyApp : public vglx::Application {
public:
auto Configure() -> void override {}
auto Setup() -> void override {
SetCamera(vglx::OrthographicCamera::Create({
.left = 0.0f,
.right = 1024.0f,
.top = 0.0f,
.bottom = 768.0f,
.near = 0.1f,
.far = 100.0f
}));
}
auto Update(float delta) -> bool override {
return true;
}
}
INFO
Derives from Camera and inherits all public properties and methods.
Construction
Constructors
OrthographicCamera()
vglx::OrthographicCamera::OrthographicCamera(const Parameters ¶ms)
Parameter | Description |
---|---|
params | OrthographicCamera::Parameters |
Constructs an OrthographicCamera object.
Factories preferred
OrthographicCamera::Create() std::shared_ptr<OrthographicCamera>
static std::shared_ptr< OrthographicCamera > vglx::OrthographicCamera::Create(const Parameters ¶ms)
Parameter | Description |
---|---|
params | OrthographicCamera::Parameters |
Creates a shared pointer to OrthographicCamera object.
Types
OrthographicCamera::ResizePolicy scoped enum
Defines how the orthographic projection should adapt on window resize.
Value | Description |
---|---|
PixelSpace | Projection matches framebuffer dimensions. |
FixedVertical | Vertical extent remains constant, horizontal adjusted. |
FixedHorizontal | Horizontal extent remains constant, vertical adjusted. |
OrthographicCamera::Parameters struct
Parameters for constructing an OrthographicCamera object.
Name | Type | Description |
---|---|---|
bottom | float | Bottom clipping plane. |
far | float | Far clipping plane. |
left | float | Left clipping plane. |
near | float | Near clipping plane. |
right | float | Right clipping plane. |
top | float | Top clipping plane. |
Properties
resize_policy ResizePolicy
ResizePolicy resize_policy { ResizePolicy::PixelSpace }
The current resize policy for this camera.
Functions
Resize() void virtual
void vglx::OrthographicCamera::Resize(int width, int height) override
Parameter | Description |
---|---|
width | Viewport width in pixels. |
height | Viewport height in pixels. |
Updates the projection transform to match the new viewport size.