Files
sophia/engine/include/sophia/camera_2d.hpp
T
2026-09-08 22:48:59 -07:00

31 lines
662 B
C++

#pragma once
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
namespace sophia {
class Camera2D {
public:
glm::vec2 position{0.f, 0.f};
void setProjection(float left, float right, float bottom, float top) {
projection = glm::ortho(left, right, bottom, top);
}
const glm::mat4& getProjection() const { return projection; }
glm::mat4 getView() const {
return glm::translate(glm::mat4(1.f), glm::vec3(-position, 0.f));
}
glm::mat4 getViewProjection() const { return projection * getView(); }
private:
glm::mat4 projection{1.f};
};
} // namespace sophia