ASGE  3.2.0
Simple Game Framework in GL
ASGE::Viewport Struct Reference

#include <Viewport.hpp>

Public Member Functions

 Viewport ()=default
 
 Viewport (int32_t xpos, int32_t ypos, int32_t width, int32_t height)
 

Public Attributes

int32_t x = 0
 
int32_t y = 0
 
int32_t w = 0
 
int32_t h = 0
 

Friends

bool operator!= (const Viewport &rhs, const Viewport &lhs)
 

Detailed Description

A viewport controls the mapping of the rendered scene on to the destination target. The destination could be a ASGE::RenderTarget or the game window itself. For example you could create a viewport that only consumed half the render window and render a camera's view in to it. This could allow for more complex game scenes such as the use of split screens.

In the following example, the game screen is split into half (vertically) with one viewport on the left and the other on the right. A camera is then used to frame the action, before rendering the first sprite, shifting the viewport and then rendering the second sprite.

split rendering
Note
Changing the size of the viewport will directly impact how the rendered sprites are mapped to the screen. This can result in distortion when your viewport has a different aspect ratio compared to the camera.
poor aspect ratio split rendering

Definition at line 43 of file Viewport.hpp.

Constructor & Destructor Documentation

◆ Viewport() [1/2]

ASGE::Viewport::Viewport ( )
default

Default constructor.

◆ Viewport() [2/2]

ASGE::Viewport::Viewport ( int32_t  xpos,
int32_t  ypos,
int32_t  width,
int32_t  height 
)
inline

The constructor for a viewport, which uses the provided dimensions.

Parameters
[in]xposThe position the X axis that the viewport should start.
[in]yposThe position the Y axis that the viewport should start.
[in]widthThe width of the viewport.
[in]heightThe height of the viewport.

Definition at line 57 of file Viewport.hpp.

Member Data Documentation

◆ h

int32_t ASGE::Viewport::h = 0

The height of the viewport

Definition at line 72 of file Viewport.hpp.

◆ w

int32_t ASGE::Viewport::w = 0

The width of the viewport

Definition at line 71 of file Viewport.hpp.

◆ x

int32_t ASGE::Viewport::x = 0

The starting X position

Definition at line 69 of file Viewport.hpp.

◆ y

int32_t ASGE::Viewport::y = 0

The starting Y position

Definition at line 70 of file Viewport.hpp.


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