#include "Camera2D.h" #include "Exception.h" Camera2D::Camera2D(const vec2& size, const vec2& position) : Camera2D(vec3(size.x, size.y, 2.0f), vec3(position.x, position.y, 0.0f)) {} Camera2D::Camera2D(const vec3& size, const vec3& position) { update_size(size); update_position(position); } void Camera2D::update_size(const vec3& size) { m_size = size; update_scale(); } void Camera2D::update_position(const vec3& position) { m_position = position; } void Camera2D::translate(const vec2& translation) { translate(vec3(translation.x, translation.y, 0.0f)); } void Camera2D::translate(const vec3& translation) { m_position += translation; } void Camera2D::prerender() { m_view_matrix[3][0] = -m_position.x; m_view_matrix[3][1] = -m_position.y; m_view_matrix[3][2] = -m_position.z; } void Camera2D::update_scale() { m_projection_matrix[0][0] = 2.0f / m_size.x; m_projection_matrix[1][1] = 2.0f / m_size.y; m_projection_matrix[2][2] = -2.0f / m_size.z; }