jGL
Loading...
Searching...
No Matches
Public Member Functions | List of all members
jGL::OrthoCam Class Reference

An orthographic camera for 2D. More...

#include <orthoCam.h>

Public Member Functions

 OrthoCam (int resx, int resy)
 Construct a new Ortho Cam object.
 
 OrthoCam (int resx, int resy, glm::vec2 pos)
 Construct a new Ortho Cam object.
 
glm::vec4 screenToWorld (float x, float y) const
 Convert screen position to world position.
 
glm::vec2 worldToScreen (float x, float y) const
 Convert world position to screen coordinate.
 
const glm::mat4 & getVP () const
 
const glm::mat4 getProjection () const
 
glm::vec2 getResolution () const
 
glm::vec2 getPosition () const
 
float getZoomLevel () const
 
void incrementZoom (float dz)
 
void setPosition (glm::vec2 newPosition)
 
void setPosition (float x, float y)
 
void move (float dx, float dy)
 
void setResolution (glm::ivec2 wh)
 

Detailed Description

An orthographic camera for 2D.

World coordinates are scaled to the size of the longest screen dimension in pixels. So [1, 1] is the top right of the screen always.

Position is the bottom left of corner. Increasing y in world space goes up the screen.

Constructor & Destructor Documentation

◆ OrthoCam() [1/2]

jGL::OrthoCam::OrthoCam ( int  resx,
int  resy 
)
inline

Construct a new Ortho Cam object.

Parameters
resxpixel resolution in x
resypixel resolution in y

◆ OrthoCam() [2/2]

jGL::OrthoCam::OrthoCam ( int  resx,
int  resy,
glm::vec2  pos 
)
inline

Construct a new Ortho Cam object.

Parameters
resxpixel resolution in x.
resypixel resolution in y.
posposition in world coordinates.

Member Function Documentation

◆ getPosition()

glm::vec2 jGL::OrthoCam::getPosition ( ) const
inline

◆ getProjection()

const glm::mat4 jGL::OrthoCam::getProjection ( ) const
inline

◆ getResolution()

glm::vec2 jGL::OrthoCam::getResolution ( ) const
inline

◆ getVP()

const glm::mat4 & jGL::OrthoCam::getVP ( ) const
inline

◆ getZoomLevel()

float jGL::OrthoCam::getZoomLevel ( ) const
inline

◆ incrementZoom()

void jGL::OrthoCam::incrementZoom ( float  dz)
inline

◆ move()

void jGL::OrthoCam::move ( float  dx,
float  dy 
)
inline

◆ screenToWorld()

glm::vec4 jGL::OrthoCam::screenToWorld ( float  x,
float  y 
) const
inline

Convert screen position to world position.

Parameters
xscreen x coordinate.
yscreen y coordinate.
Returns
glm::vec4 world coordinates (wx, wy, _, 1.0)

◆ setPosition() [1/2]

void jGL::OrthoCam::setPosition ( float  x,
float  y 
)
inline

◆ setPosition() [2/2]

void jGL::OrthoCam::setPosition ( glm::vec2  newPosition)
inline

◆ setResolution()

void jGL::OrthoCam::setResolution ( glm::ivec2  wh)
inline

◆ worldToScreen()

glm::vec2 jGL::OrthoCam::worldToScreen ( float  x,
float  y 
) const
inline

Convert world position to screen coordinate.

Parameters
xworld x coordinate.
yworld y coordinate.
Returns
glm::vec2 screen coordinate.

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