FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
fge::View Class Reference

Define a camera in a 2D scene. More...

#include <C_view.hpp>

Public Member Functions

 View (fge::vulkan::Viewport const &viewport)
 
 View (Vector2f const &center, Vector2f const &size)
 
void setCenter (Vector2f const &center)
 
Vector2f const & getCenter () const
 
void setSize (Vector2f const &size)
 Set the size of the view.
 
Vector2f const & getSize () const
 
void setRotation (float angleDeg)
 
float getRotation () const
 
void setFactorViewport (fge::RectFloat const &factorViewport)
 Set the viewport rectangle of the view.
 
fge::RectFloat const & getFactorViewport () const
 
void reset (fge::vulkan::Viewport const &viewport)
 Reset the view to the given viewport.
 
void move (Vector2f const &offset)
 Helper function to move the view.
 
void rotate (float angle)
 Helper function to rotate the view.
 
void zoom (float factor)
 Helper function to zoom the view.
 
void resizeFixCenter (fge::Vector2f const &newSize)
 Resize the view and move it relatively to old center in order to expand it.
 
glm::mat4 const & getTransform () const
 Get the transform of the view.
 
glm::mat4 const & getInverseTransform () const
 
glm::mat4 const & getProjection () const
 Get the projection matrix of the view.
 
glm::mat4 const & getInverseProjection () const
 

Detailed Description

Define a camera in a 2D scene.

A view is a 2D camera that defines what part of the 2D scene is visible.

Member Function Documentation

◆ getProjection()

glm::mat4 const & fge::View::getProjection ( ) const
nodiscard

Get the projection matrix of the view.

This function returns the a orthogonal projection matrix.

Returns
A glm::mat4 of the projection

◆ getTransform()

glm::mat4 const & fge::View::getTransform ( ) const
nodiscard

Get the transform of the view.

This function returns the transform matrix.

Returns
A glm::mat4 of the view

◆ move()

void fge::View::move ( Vector2f const & offset)

Helper function to move the view.

Parameters
offsetOffset to apply to the view

◆ reset()

void fge::View::reset ( fge::vulkan::Viewport const & viewport)

Reset the view to the given viewport.

The size and center of the view are adjusted so that the entire viewport is visible. The rotation is reset to 0.

Parameters
viewportNew viewport to apply to the view

◆ resizeFixCenter()

void fge::View::resizeFixCenter ( fge::Vector2f const & newSize)

Resize the view and move it relatively to old center in order to expand it.

Parameters
newSizeNew size of the view

◆ rotate()

void fge::View::rotate ( float angle)

Helper function to rotate the view.

Parameters
angleAngle to apply to the view, in degrees

◆ setFactorViewport()

void fge::View::setFactorViewport ( fge::RectFloat const & factorViewport)

Set the viewport rectangle of the view.

The viewport is the rectangle into which the contents of the view are displayed, expressed as a factor (between 0 and 1) of the size of the RenderTarget to which the view is applied.

For example, a view which takes the left side of the target would be defined by:

view.setViewport({{0.0f, 0.0f}, {0.5f, 1.0f}});
Parameters
factorViewportNew viewport rectangle, expressed as a factor of the render-target's size

◆ setSize()

void fge::View::setSize ( Vector2f const & size)

Set the size of the view.

A size smaller than the target will display a zoomed area, while a size greater than the target will show a bigger area.

Parameters
sizeNew size of the view

◆ zoom()

void fge::View::zoom ( float factor)

Helper function to zoom the view.

Parameters
factorZoom factor to apply to the view

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