Gamedev Framework (gf)  0.17.0
A C++14 framework for 2D games
Public Member Functions | List of all members
gf::AdaptativeView Class Referenceabstract

Adaptative view. More...

#include <gf/View.h>

Inheritance diagram for gf::AdaptativeView:
Inheritance graph
[legend]

Public Member Functions

 AdaptativeView ()
 Default constructor. More...
 
 AdaptativeView (const RectF &rect)
 Construct the view from a rectangle. More...
 
 AdaptativeView (Vector2f center, Vector2f size)
 Construct the view from its center and size. More...
 
void setInitialFramebufferSize (Vector2i framebufferSize)
 Set the initial framebuffer size. More...
 
void setInitialScreenSize (Vector2i screenSize)
 Set the initial screen size. More...
 
virtual void onFramebufferSizeChange (Vector2i framebufferSize)=0
 Callback when the framebuffer has just been resized. More...
 
- Public Member Functions inherited from gf::View
 View ()
 Default constructor. More...
 
 View (const RectF &rect)
 Construct the view from a rectangle. More...
 
 View (Vector2f center, Vector2f size)
 Construct the view from its center and size. More...
 
virtual ~View ()
 Destructor. More...
 
RectF getBounds () const
 Get the non-rotated bounds. More...
 
void setCenter (Vector2f center)
 Set the center of the view. More...
 
Vector2f getCenter () const
 Get the center of the view. More...
 
void setSize (Vector2f size)
 Set the size of the view. More...
 
Vector2f getSize () const
 Get the size of the view. More...
 
void setRotation (float angle)
 Set the orientation of the view. More...
 
float getRotation () const
 Get the current orientation of the view. More...
 
void setViewport (const RectF &viewport)
 Set the target viewport. More...
 
const RectFgetViewport () const
 Get the target viewport rectangle of the view. More...
 
void reset (const RectF &rect)
 Reset the view to the given rectangle. More...
 
void move (Vector2f offset)
 Move the view relatively to its current position. More...
 
void rotate (float angle)
 Rotate the view relatively to its current orientation. More...
 
void zoom (float factor)
 Resize the view rectangle relatively to its current size. More...
 
void zoom (float factor, Vector2f fixed)
 Resize the view rectangle relatively to its current size and a fixed point. More...
 
Matrix3f getTransform () const
 Get the projection transform of the view. More...
 
Matrix3f getInverseTransform () const
 Get the inverse projection transform of the view. More...
 

Additional Inherited Members

- Protected Member Functions inherited from gf::View
void setSizeNoCallback (Vector2f size)
 Set the world size, without calling onSizeChange() More...
 
virtual void onSizeChange (Vector2f size)
 Callback when the world has just been resized. More...
 
void setViewportNoCallback (const RectF &viewport)
 Set the viewport, without calling onViewportChange() More...
 
virtual void onViewportChange (const RectF &viewport)
 Callback when the viewport has just been changed. More...
 

Detailed Description

Adaptative view.

An adaptative view is a view that adapts automatically to framebuffer resolution change.

There are several kinds of adaptative views, according to the policy that is adopted when the resolution changes. In the examples below, The framebuffer is represented by the black rectangle and the world is the red square. If red dashed lines appears, it means that the world has been modified.

Class Example
gf::StretchView
stretchview.png
gf::FitView
fitview.png
gf::FillView
fillview.png
gf::ExtendView
extendview.png
gf::LockedView
lockedview.png
gf::ScreenView
screenview.png
See also
gf::ViewContainer

Constructor & Destructor Documentation

◆ AdaptativeView() [1/3]

gf::AdaptativeView::AdaptativeView ( )
inline

Default constructor.

This constructor creates a default view of \((0, 0, 1000, 1000)\).

◆ AdaptativeView() [2/3]

gf::AdaptativeView::AdaptativeView ( const RectF rect)
inlineexplicit

Construct the view from a rectangle.

Parameters
rectRectangle defining the zone to display

◆ AdaptativeView() [3/3]

gf::AdaptativeView::AdaptativeView ( Vector2f  center,
Vector2f  size 
)
inline

Construct the view from its center and size.

Parameters
centerCenter of the zone to display
sizeSize of the zone to display

Member Function Documentation

◆ onFramebufferSizeChange()

virtual void gf::AdaptativeView::onFramebufferSizeChange ( Vector2i  framebufferSize)
pure virtual

Callback when the framebuffer has just been resized.

Parameters
framebufferSizeThe new size of the framebuffer

Implemented in gf::ScreenView, gf::LockedView, gf::ExtendView, gf::FillView, gf::FitView, and gf::StretchView.

◆ setInitialFramebufferSize()

void gf::AdaptativeView::setInitialFramebufferSize ( Vector2i  framebufferSize)

Set the initial framebuffer size.

Parameters
framebufferSizeThe initial size of the framebuffer

◆ setInitialScreenSize()

void gf::AdaptativeView::setInitialScreenSize ( Vector2i  screenSize)
inline

Set the initial screen size.

Parameters
screenSizeThe initial size of the screen
Deprecated:
You should use setInitialFramebufferSize() instead