libdonut  2.3.2
Application framework for cross-platform game development in C++20
Public Member Functions | Static Public Member Functions | List of all members
donut::graphics::Camera Class Reference

Combined view-projection matrix, defining the perspective for a Renderer to render from. More...

#include <donut/graphics/Camera.hpp>

Public Member Functions

constexpr Camera () noexcept
 Construct a camera with an identity projection matrix and view matrix. More...
 
constexpr Camera (const mat4 &projectionMatrix, const mat4 &viewMatrix) noexcept
 Construct a camera with a specific projection matrix and view matrix. More...
 
void setProjectionOrthographic (const CameraOrthographicOptions &options) noexcept
 Set the projection of the camera to an orthographic projection. More...
 
void setProjectionPerspective (const CameraPerspectiveOptions &options) noexcept
 Set the projection of the camera to a perspective projection. More...
 
void setView (vec3 newPosition, vec3 newTarget, vec3 newUp) noexcept
 Set the view of the camera. More...
 
void setProjectionMatrix (const mat4 &newProjectionMatrix) noexcept
 Set the projection matrix of the camera. More...
 
void setViewMatrix (const mat4 &newViewMatrix) noexcept
 Set the view matrix of the camera. More...
 
const mat4 & getProjectionMatrix () const noexcept
 Get the projection matrix of the camera. More...
 
const mat4 & getViewMatrix () const noexcept
 Get the view matrix of the camera. More...
 

Static Public Member Functions

static Camera createOrthographic (const CameraOrthographicOptions &options, const mat4 &viewMatrix) noexcept
 Create a camera with an orthographic projection. More...
 
static Camera createOrthographic (const CameraOrthographicOptions &options) noexcept
 Create a camera with an orthographic projection and an identity view matrix at the default position. More...
 
static Camera createOrthographic (const CameraOrthographicOptions &options, vec3 position, vec3 target, vec3 up) noexcept
 Create a camera with an orthographic projection. More...
 
static Camera createPerspective (const CameraPerspectiveOptions &options, const mat4 &viewMatrix) noexcept
 Create a camera with a perspective projection. More...
 
static Camera createPerspective (const CameraPerspectiveOptions &options) noexcept
 Create a camera with a perspective projection and an identity view matrix at the default position. More...
 
static Camera createPerspective (const CameraPerspectiveOptions &options, vec3 position, vec3 target, vec3 up) noexcept
 Create a camera with a perspective projection. More...
 

Detailed Description

Combined view-projection matrix, defining the perspective for a Renderer to render from.

Examples
example_game.cpp, and example_rectangle.cpp.

Constructor & Destructor Documentation

◆ Camera() [1/2]

constexpr donut::graphics::Camera::Camera ( )
inlineconstexprnoexcept

Construct a camera with an identity projection matrix and view matrix.

◆ Camera() [2/2]

constexpr donut::graphics::Camera::Camera ( const mat4 &  projectionMatrix,
const mat4 &  viewMatrix 
)
inlineconstexprnoexcept

Construct a camera with a specific projection matrix and view matrix.

Parameters
projectionMatrixprojection matrix of the camera.
viewMatrixview matrix of the camera.

Member Function Documentation

◆ createOrthographic() [1/3]

static Camera donut::graphics::Camera::createOrthographic ( const CameraOrthographicOptions options,
const mat4 &  viewMatrix 
)
inlinestaticnoexcept

Create a camera with an orthographic projection.

Parameters
optionsprojection options, see CameraOrthographicOptions.
viewMatrixview matrix of the camera.
Returns
an orthographic camera with the specified configuration.
Examples
example_game.cpp, and example_rectangle.cpp.

◆ createOrthographic() [2/3]

static Camera donut::graphics::Camera::createOrthographic ( const CameraOrthographicOptions options)
inlinestaticnoexcept

Create a camera with an orthographic projection and an identity view matrix at the default position.

Parameters
optionsprojection options, see CameraOrthographicOptions.
Returns
an orthographic camera with the specified configuration.

◆ createOrthographic() [3/3]

static Camera donut::graphics::Camera::createOrthographic ( const CameraOrthographicOptions options,
vec3  position,
vec3  target,
vec3  up 
)
inlinestaticnoexcept

Create a camera with an orthographic projection.

Parameters
optionsprojection options, see CameraOrthographicOptions.
positionposition of the camera, in world coordinates.
targettarget position to aim the camera at, in world coordinates.
upup direction of the camera in the world.
Returns
an orthographic camera with the specified configuration.

◆ createPerspective() [1/3]

static Camera donut::graphics::Camera::createPerspective ( const CameraPerspectiveOptions options,
const mat4 &  viewMatrix 
)
inlinestaticnoexcept

Create a camera with a perspective projection.

Parameters
optionsprojection options, see CameraPerspectiveOptions.
viewMatrixview matrix of the camera.
Returns
an orthographic camera with the specified configuration.
Examples
example_game.cpp.

◆ createPerspective() [2/3]

static Camera donut::graphics::Camera::createPerspective ( const CameraPerspectiveOptions options)
inlinestaticnoexcept

Create a camera with a perspective projection and an identity view matrix at the default position.

Parameters
optionsprojection options, see CameraPerspectiveOptions.
Returns
an orthographic camera with the specified configuration.

◆ createPerspective() [3/3]

static Camera donut::graphics::Camera::createPerspective ( const CameraPerspectiveOptions options,
vec3  position,
vec3  target,
vec3  up 
)
inlinestaticnoexcept

Create a camera with a perspective projection.

Parameters
optionsprojection options, see CameraPerspectiveOptions.
positionposition of the camera, in world coordinates.
targettarget position to aim the camera at, in world coordinates.
upup direction of the camera in the world.
Returns
an orthographic camera with the specified configuration.

◆ setProjectionOrthographic()

void donut::graphics::Camera::setProjectionOrthographic ( const CameraOrthographicOptions options)
inlinenoexcept

Set the projection of the camera to an orthographic projection.

Parameters
optionsprojection options, see CameraOrthographicOptions.

◆ setProjectionPerspective()

void donut::graphics::Camera::setProjectionPerspective ( const CameraPerspectiveOptions options)
inlinenoexcept

Set the projection of the camera to a perspective projection.

Parameters
optionsprojection options, see CameraPerspectiveOptions.

◆ setView()

void donut::graphics::Camera::setView ( vec3  newPosition,
vec3  newTarget,
vec3  newUp 
)
inlinenoexcept

Set the view of the camera.

Parameters
newPositionnew position of the camera, in world coordinates.
newTargetnew target position to aim the camera at, in world coordinates.
newUpnew up direction of the camera in the world.

◆ setProjectionMatrix()

void donut::graphics::Camera::setProjectionMatrix ( const mat4 &  newProjectionMatrix)
inlinenoexcept

Set the projection matrix of the camera.

Parameters
newProjectionMatrixnew projection matrix to set.

◆ setViewMatrix()

void donut::graphics::Camera::setViewMatrix ( const mat4 &  newViewMatrix)
inlinenoexcept

Set the view matrix of the camera.

Parameters
newViewMatrixnew view matrix to set.

◆ getProjectionMatrix()

const mat4& donut::graphics::Camera::getProjectionMatrix ( ) const
inlinenoexcept

Get the projection matrix of the camera.

Returns
the camera's current projection matrix.

◆ getViewMatrix()

const mat4& donut::graphics::Camera::getViewMatrix ( ) const
inlinenoexcept

Get the view matrix of the camera.

Returns
the camera's current view matrix.

The documentation for this class was generated from the following file: