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