]> git.localhorst.tv Git - blank.git/blob - src/graphics/Viewport.hpp
96fbaa4deae54840efb53a1bb7fa2474a17d1b21
[blank.git] / src / graphics / Viewport.hpp
1 #ifndef BLANK_GRAPHICS_VIEWPORT_HPP_
2 #define BLANK_GRAPHICS_VIEWPORT_HPP_
3
4 #include "align.hpp"
5 #include "BlendedSprite.hpp"
6 #include "BlockLighting.hpp"
7 #include "Camera.hpp"
8 #include "Canvas.hpp"
9 #include "DirectionalLighting.hpp"
10 #include "PlainColor.hpp"
11 #include "SkyBoxShader.hpp"
12
13 #include <glm/glm.hpp>
14
15
16 namespace blank {
17
18 class Viewport {
19
20 public:
21         Viewport();
22
23         Viewport(const Viewport &) = delete;
24         Viewport &operator =(const Viewport &) = delete;
25
26         void VSync(bool b) noexcept;
27
28         void EnableDepthTest() noexcept;
29         void EqualDepthTest() noexcept;
30         void DisableDepthTest() noexcept;
31
32         void EnableBackfaceCulling() noexcept;
33         void DisableBackfaceCulling() noexcept;
34
35         void EnableAlphaBlending() noexcept;
36         void EnableInvertBlending() noexcept;
37         void DisableBlending() noexcept;
38
39         void Resize(int w, int h) noexcept;
40
41         float Width() const noexcept { return canv.Size().x; }
42         float Height() const noexcept { return canv.Size().y; }
43
44         void Clear() noexcept;
45         void ClearDepth() noexcept;
46
47         glm::vec2 GetPosition(const glm::vec2 &off, Gravity grav) const noexcept;
48
49         void SetCursor(const glm::vec3 &) noexcept;
50         void SetCursor(const glm::vec3 &, Gravity) noexcept;
51         void MoveCursor(const glm::vec3 &) noexcept;
52         const glm::mat4 &Cursor() const noexcept { return cursor; }
53
54         BlockLighting &ChunkProgram() noexcept;
55         DirectionalLighting &EntityProgram() noexcept;
56         DirectionalLighting &HUDProgram() noexcept;
57         PlainColor &WorldColorProgram() noexcept;
58         PlainColor &HUDColorProgram() noexcept;
59         SkyBoxShader &SkyBoxProgram() noexcept;
60         BlendedSprite &SpriteProgram() noexcept;
61
62         void WorldPosition(const glm::mat4 &) noexcept;
63
64         const glm::mat4 &Perspective() const noexcept { return cam.Projection(); }
65         const glm::mat4 &Ortho() const noexcept { return canv.Projection(); }
66
67 private:
68         Camera cam;
69         Canvas canv;
70
71         glm::mat4 cursor;
72
73         BlockLighting chunk_prog;
74         DirectionalLighting entity_prog;
75         PlainColor color_prog;
76         SkyBoxShader sky_prog;
77         BlendedSprite sprite_prog;
78
79         enum {
80                 NONE,
81                 CHUNK,
82                 ENTITY,
83                 HUD,
84                 COLOR_WORLD,
85                 COLOR_HUD,
86                 SKY_BOX,
87                 SPRITE,
88         } active_prog;
89
90 };
91
92 }
93
94 #endif