]> git.localhorst.tv Git - blank.git/blob - src/camera.hpp
add SDL2_image library
[blank.git] / src / camera.hpp
1 #ifndef BLANK_CAMERA_HPP_
2 #define BLANK_CAMERA_HPP_
3
4 #include <glm/glm.hpp>
5
6
7 namespace blank {
8
9 class Camera {
10
11 public:
12         Camera();
13         ~Camera();
14
15         Camera(const Camera &) = delete;
16         Camera &operator =(const Camera &) = delete;
17
18         glm::mat4 MakeMVP(const glm::mat4 &m) const { return vp * m; }
19
20         void Viewport(int width, int height);
21         void Viewport(int x, int y, int width, int height);
22
23         void FOV(float f);
24         void Aspect(float r);
25         void Aspect(float w, float h);
26         void Clip(float near, float far);
27
28         void Position(glm::vec3 pos) { position = pos; UpdateView(); }
29         void Move(glm::vec3 delta) { position += delta; UpdateView(); }
30
31         void LookAt(glm::vec3 tgt) { target = tgt; UpdateView(); }
32
33 private:
34         void UpdateProjection();
35         void UpdateView();
36
37 private:
38         float fov;
39         float aspect;
40         float near_clip;
41         float far_clip;
42
43         glm::vec3 position;
44         glm::vec3 target;
45         glm::vec3 up;
46
47         glm::mat4 projection;
48         glm::mat4 view;
49         glm::mat4 vp;
50
51 };
52
53 }
54
55 #endif