29 lines
604 B
C++
29 lines
604 B
C++
#pragma once
|
|
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
#include <sophia/math.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
|