GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::graphics::Camera2D Class Reference

Combined view-projection matrix, defining a 2D perspective to render from. More...

#include <GREM/graphics_2d/Camera2D.hpp>

Classes

struct  Parameters
 Struct of shader parameters representing the state of a Camera2D. More...

Public Types

using ParameterBuffer = UniformBuffer<Parameters, "Camera2DParameters">
 Shader buffer for 2D camera parameters.

Public Member Functions

 Camera2D (Device &device, const Projection2D &projection=mat3{1.0f}, const View2D &view=mat3{1.0f}, const Camera2DOptions &options={})
 Construct a camera.
void setProjection (const Projection2D &newProjection)
 Set the projection of the camera.
void setView (const View2D &newView)
 Set the view of the camera.
void setOptions (const Camera2DOptions &newOptions)
 Set the configuration options of the camera.
void setProjectionAndView (const Projection2D &newProjection, const View2D &newView)
 Set both the projection and view of the camera.
void setViewAndOptions (const View2D &newView, const Camera2DOptions &newOptions)
 Set both the view and configuration options of the camera.
void setProjectionAndViewAndOptions (const Projection2D &newProjection, const View2D &newView, const Camera2DOptions &newOptions)
 Set both the projection and view of the camera, as well as its configuration options.
const ParameterBuffer & getParameterBuffer () const noexcept
 Get the parameter buffer of the camera.
const mat3 & getProjectionMatrix () const noexcept
 Get the projection matrix of the camera.
const mat3 & getViewMatrix () const noexcept
 Get the view matrix of the camera.
Camera2DOptions getOptions () const noexcept
 Get the configuration options of the camera.

Detailed Description

Combined view-projection matrix, defining a 2D perspective to render from.

Member Typedef Documentation

◆ ParameterBuffer

Shader buffer for 2D camera parameters.

Constructor & Destructor Documentation

◆ Camera2D()

grem::graphics::Camera2D::Camera2D ( Device & device,
const Projection2D & projection = mat3{1.0f},
const View2D & view = mat3{1.0f},
const Camera2DOptions & options = {} )
inlineexplicit

Construct a camera.

Parameters
devicedevice to create the camera for. Must outlive the camera.
projectionprojection matrix or configuration options for the camera projection, see Projection2D.
viewview matrix or configuration options for the camera view, see View2D.
optionscamera options, see Camera3DOptions.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

Member Function Documentation

◆ setProjection()

void grem::graphics::Camera2D::setProjection ( const Projection2D & newProjection)
inline

Set the projection of the camera.

Parameters
newProjectionnew projection matrix or configuration options for the camera projection, see Projection2D.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ setView()

void grem::graphics::Camera2D::setView ( const View2D & newView)
inline

Set the view of the camera.

Parameters
newViewnew view matrix or configuration options for the camera view, see View2D.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ setOptions()

void grem::graphics::Camera2D::setOptions ( const Camera2DOptions & newOptions)
inline

Set the configuration options of the camera.

Parameters
newOptionsnew configuration options, see Camera2DOptions.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ setProjectionAndView()

void grem::graphics::Camera2D::setProjectionAndView ( const Projection2D & newProjection,
const View2D & newView )
inline

Set both the projection and view of the camera.

Parameters
newProjectionnew projection matrix or configuration options for the camera projection, see Projection2D.
newViewnew view matrix or configuration options for the camera view, see View2D.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ setViewAndOptions()

void grem::graphics::Camera2D::setViewAndOptions ( const View2D & newView,
const Camera2DOptions & newOptions )
inline

Set both the view and configuration options of the camera.

Parameters
newViewnew view matrix or configuration options for the camera view, see View2D.
newOptionsnew configuration options, see Camera2DOptions.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ setProjectionAndViewAndOptions()

void grem::graphics::Camera2D::setProjectionAndViewAndOptions ( const Projection2D & newProjection,
const View2D & newView,
const Camera2DOptions & newOptions )
inline

Set both the projection and view of the camera, as well as its configuration options.

Parameters
newProjectionnew projection matrix or configuration options for the camera projection, see Projection2D.
newViewnew view matrix or configuration options for the camera view, see View2D.
newOptionsnew configuration options, see Camera2DOptions.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ getParameterBuffer()

const ParameterBuffer & grem::graphics::Camera2D::getParameterBuffer ( ) const
inlinenodiscardnoexcept

Get the parameter buffer of the camera.

Returns
a read-only reference to the camera's parameter buffer.

◆ getProjectionMatrix()

const mat3 & grem::graphics::Camera2D::getProjectionMatrix ( ) const
inlinenodiscardnoexcept

Get the projection matrix of the camera.

Returns
a read-only reference to the camera's current projection matrix.

◆ getViewMatrix()

const mat3 & grem::graphics::Camera2D::getViewMatrix ( ) const
inlinenodiscardnoexcept

Get the view matrix of the camera.

Returns
a read-only reference to the camera's current view matrix.

◆ getOptions()

Camera2DOptions grem::graphics::Camera2D::getOptions ( ) const
inlinenodiscardnoexcept

Get the configuration options of the camera.

Returns
the camera's current options.

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