]> git.localhorst.tv Git - blobs.git/blob - src/graphics/PlanetSurface.hpp
178fcabac98123ad6914a8e01b45e9079f3cac4b
[blobs.git] / src / graphics / PlanetSurface.hpp
1 #ifndef BLOBS_GRAPHICS_PLANETSURFACE_HPP_
2 #define BLOBS_GRAPHICS_PLANETSURFACE_HPP_
3
4 #include "Program.hpp"
5
6 #include "glm.hpp"
7
8
9 namespace blobs {
10 namespace graphics {
11
12 class ArrayTexture;
13
14 class PlanetSurface {
15
16 public:
17         static constexpr int MAX_LIGHTS = 8;
18
19 public:
20         PlanetSurface();
21         ~PlanetSurface();
22
23         PlanetSurface(const PlanetSurface &) = delete;
24         PlanetSurface &operator =(const PlanetSurface &) = delete;
25
26         PlanetSurface(PlanetSurface &&) = delete;
27         PlanetSurface &operator =(PlanetSurface &&) = delete;
28
29 public:
30         void Activate() noexcept;
31
32         void SetM(const glm::mat4 &m) noexcept;
33         void SetVP(const glm::mat4 &v, const glm::mat4 &p) noexcept;
34         void SetMVP(const glm::mat4 &m, const glm::mat4 &v, const glm::mat4 &p) noexcept;
35         void SetNormal(const glm::vec3 &) noexcept;
36         void SetTexture(ArrayTexture &) noexcept;
37         void SetLight(int n, const glm::vec3 &pos, const glm::vec3 &color, float strength) noexcept;
38         void SetNumLights(int n) noexcept;
39
40         const glm::mat4 &M() const noexcept { return m; }
41         const glm::mat4 &V() const noexcept { return v; }
42         const glm::mat4 &P() const noexcept { return p; }
43         const glm::mat4 &MV() const noexcept { return mv; }
44         const glm::mat4 &MVP() const noexcept { return mvp; }
45
46 private:
47         Program prog;
48
49         int num_lights;
50
51         glm::mat4 m;
52         glm::mat4 v;
53         glm::mat4 p;
54         glm::mat4 mv;
55         glm::mat4 mvp;
56
57         GLuint m_handle;
58         GLuint mv_handle;
59         GLuint mvp_handle;
60         GLuint sampler_handle;
61         GLuint normal_handle;
62
63         GLuint num_lights_handle;
64         GLuint light_handle[MAX_LIGHTS * 3];
65
66 };
67
68 }
69 }
70
71 #endif