31 lines
621 B
C++
31 lines
621 B
C++
#pragma once
|
|
|
|
#include "glm/glm.hpp"
|
|
#include "glm/ext/matrix_transform.hpp"
|
|
#include "glm/gtc/matrix_transform.hpp"
|
|
|
|
class Camera {
|
|
private:
|
|
glm::mat4 projection;
|
|
glm::mat4 view;
|
|
glm::mat4 viewProj;
|
|
|
|
public:
|
|
Camera(float fov, float width, float height) {
|
|
projection = glm::perspective(fov/2.0f, width/height, 0.1f, 1000.f);
|
|
view = glm::mat4(1.0f);
|
|
update();
|
|
}
|
|
|
|
glm::mat4 getViewProj() {
|
|
return viewProj;
|
|
}
|
|
|
|
void update() {
|
|
viewProj = projection * view;
|
|
}
|
|
|
|
void translate(glm::vec3 v) {
|
|
view = glm::translate(view, v*-1.0f);
|
|
}
|
|
}; |