1#ifndef DONUT_GRAPHICS_CAMERA_HPP 
    2#define DONUT_GRAPHICS_CAMERA_HPP 
   64        return Camera{ortho(options.offset.x, options.offset.x + options.size.x, options.offset.y, options.offset.y + options.size.y), viewMatrix};
 
 
  101        return Camera{perspective(options.verticalFieldOfView, options.aspectRatio, options.nearZ, options.farZ), viewMatrix};
 
 
  134        : projectionMatrix(identity<mat4>())
 
  135        , viewMatrix(identity<mat4>()) {}
 
 
  143    constexpr Camera(
const mat4& projectionMatrix, 
const mat4& viewMatrix) noexcept
 
  144        : projectionMatrix(projectionMatrix)
 
  145        , viewMatrix(viewMatrix) {}
 
 
  153        setProjectionMatrix(ortho(options.offset.x, options.offset.x + options.size.x, options.offset.y, options.offset.y + options.size.y));
 
 
  162        setProjectionMatrix(perspective(options.verticalFieldOfView, options.aspectRatio, options.nearZ, options.farZ));
 
 
  173    void setView(vec3 newPosition, vec3 newTarget, vec3 newUp) 
noexcept {
 
 
  183        projectionMatrix = newProjectionMatrix;
 
 
  192        viewMatrix = newViewMatrix;
 
 
  201        return projectionMatrix;
 
 
  214    mat4 projectionMatrix;
 
 
Combined view-projection matrix, defining the perspective for a Renderer to render from.
Definition Camera.hpp:53
 
static Camera createPerspective(const CameraPerspectiveOptions &options) noexcept
Create a camera with a perspective projection and an identity view matrix at the default position.
Definition Camera.hpp:112
 
void setView(vec3 newPosition, vec3 newTarget, vec3 newUp) noexcept
Set the view of the camera.
Definition Camera.hpp:173
 
static Camera createPerspective(const CameraPerspectiveOptions &options, vec3 position, vec3 target, vec3 up) noexcept
Create a camera with a perspective projection.
Definition Camera.hpp:126
 
static Camera createOrthographic(const CameraOrthographicOptions &options, const mat4 &viewMatrix) noexcept
Create a camera with an orthographic projection.
Definition Camera.hpp:63
 
const mat4 & getViewMatrix() const noexcept
Get the view matrix of the camera.
Definition Camera.hpp:209
 
constexpr Camera() noexcept
Construct a camera with an identity projection matrix and view matrix.
Definition Camera.hpp:133
 
void setProjectionPerspective(const CameraPerspectiveOptions &options) noexcept
Set the projection of the camera to a perspective projection.
Definition Camera.hpp:161
 
constexpr Camera(const mat4 &projectionMatrix, const mat4 &viewMatrix) noexcept
Construct a camera with a specific projection matrix and view matrix.
Definition Camera.hpp:143
 
static Camera createOrthographic(const CameraOrthographicOptions &options, vec3 position, vec3 target, vec3 up) noexcept
Create a camera with an orthographic projection.
Definition Camera.hpp:89
 
static Camera createOrthographic(const CameraOrthographicOptions &options) noexcept
Create a camera with an orthographic projection and an identity view matrix at the default position.
Definition Camera.hpp:75
 
const mat4 & getProjectionMatrix() const noexcept
Get the projection matrix of the camera.
Definition Camera.hpp:200
 
void setProjectionOrthographic(const CameraOrthographicOptions &options) noexcept
Set the projection of the camera to an orthographic projection.
Definition Camera.hpp:152
 
void setViewMatrix(const mat4 &newViewMatrix) noexcept
Set the view matrix of the camera.
Definition Camera.hpp:191
 
void setProjectionMatrix(const mat4 &newProjectionMatrix) noexcept
Set the projection matrix of the camera.
Definition Camera.hpp:182
 
static Camera createPerspective(const CameraPerspectiveOptions &options, const mat4 &viewMatrix) noexcept
Create a camera with a perspective projection.
Definition Camera.hpp:100
 
Configuration options for a Camera with an orthographic projection.
Definition Camera.hpp:11
 
vec2 offset
Bottom left corner of the orthographic projection, in framebuffer coordinates.
Definition Camera.hpp:16
 
vec2 size
Size of the orthographic projection, in framebuffer coordinates.
Definition Camera.hpp:21
 
Configuration options for a Camera with a perspective projection.
Definition Camera.hpp:27
 
float verticalFieldOfView
Vertical field of view of the projection, in radians.
Definition Camera.hpp:31
 
float aspectRatio
Aspect ratio of the projection, X/Y.
Definition Camera.hpp:36
 
float nearZ
Distance to the near plane of the projection, in view coordinates.
Definition Camera.hpp:41
 
float farZ
Distance to the far plane of the projection, in view coordinates.
Definition Camera.hpp:46