 |
BARE2D
|
|
Go to the documentation of this file.
3 #include <glm/gtc/matrix_transform.hpp>
10 m_resolution(1.0f, 1.0f), m_cameraMatrix(glm::mat4(0.0f)), m_orthographicMatrix(glm::mat4(0.0f)),
11 m_matrixNeedsUpdate(true) {
41 glm::vec3 translation = -glm::vec3(statePosition.x, statePosition.y, 0.0f);
88 glm::vec2 result = size;
96 glm::vec2 result = size;
104 glm::vec2 pos = glm::vec2(destRect.x, destRect.y);
105 glm::vec2 size = glm::vec2(destRect.z, destRect.w);
110 return glm::vec4(pos.x, pos.y, size.x, size.y);
114 glm::vec2 pos = glm::vec2(destRect.x, destRect.y);
115 glm::vec2 size = glm::vec2(destRect.z, destRect.w);
120 return glm::vec4(pos.x, pos.y, size.x, size.y);
void init(float screenWidth, float screenHeight)
Initializes the camera.
void offsetScale(float deltaScaleX, float deltaScaleY)
Adds to the zoom factor of the camera.
bool isRectInViewspace(glm::vec4 &destRect) const
glm::mat4 m_orthographicMatrix
glm::vec2 getScale() const
const glm::mat4 & getCameraMatrix() const
glm::vec2 getViewspaceCoord(glm::vec2 pos) const
Converts a coordinate from Worldspace to Viewspace.
void setFocus(glm::vec2 newFocus)
Sets the center of the camera to newFocus.
glm::vec2 getWorldspaceCoord(glm::vec2 pos) const
Converts a coordinate from Worldspace to Viewspace.
glm::vec2 getStatePosition() const
glm::vec2 getViewspaceSize(glm::vec2 size) const
Holds some basic information that the camera holds in a state.
glm::vec4 getViewspaceRect(glm::vec4 destRect) const
void offsetFocus(glm::vec2 deltaPos)
Moves the center of the camera to focus + deltaPos.
void update()
Updates the matrix if necessary.
glm::vec4 getWorldspaceRect(glm::vec4 destRect) const
glm::vec2 getViewspaceResolution() const
CameraState getLastState()
void setScale(float newScaleX, float newScaleY)
Sets the scale of the camera.
glm::vec2 getFocus() const
glm::vec2 getWorldspaceSize(glm::vec2 size) const