]> git.localhorst.tv Git - blank.git/blob - src/graphics/Viewport.hpp
combine text handling stuff into a class
[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
11 #include <glm/glm.hpp>
12
13
14 namespace blank {
15
16 class Viewport {
17
18 public:
19         Viewport();
20
21         Viewport(const Viewport &) = delete;
22         Viewport &operator =(const Viewport &) = delete;
23
24         void VSync(bool b) noexcept;
25
26         void EnableDepthTest() noexcept;
27         void DisableDepthTest() noexcept;
28
29         void EnableBackfaceCulling() noexcept;
30         void DisableBackfaceCulling() noexcept;
31
32         void EnableAlphaBlending() noexcept;
33         void EnableInvertBlending() noexcept;
34         void DisableBlending() noexcept;
35
36         void Resize(int w, int h) noexcept;
37
38         float Width() const noexcept { return canv.Size().x; }
39         float Height() const noexcept { return canv.Size().y; }
40
41         void Clear() noexcept;
42         void ClearDepth() noexcept;
43
44         void SetCursor(const glm::vec3 &);
45         void SetCursor(const glm::vec3 &, Gravity = Gravity::NORTH_WEST);
46         void MoveCursor(const glm::vec3 &);
47         const glm::mat4 &Cursor() const noexcept { return cursor; }
48
49         BlockLighting &ChunkProgram() noexcept;
50         DirectionalLighting &EntityProgram() noexcept;
51         DirectionalLighting &HUDProgram() noexcept;
52         BlendedSprite &SpriteProgram() noexcept;
53
54         void WorldPosition(const glm::mat4 &) noexcept;
55
56         const glm::mat4 &Perspective() const noexcept { return cam.Projection(); }
57         const glm::mat4 &Ortho() const noexcept { return canv.Projection(); }
58
59 private:
60         Camera cam;
61         Canvas canv;
62
63         glm::mat4 cursor;
64
65         BlockLighting chunk_prog;
66         DirectionalLighting entity_prog;
67         BlendedSprite sprite_prog;
68
69         enum {
70                 NONE,
71                 CHUNK,
72                 ENTITY,
73                 HUD,
74                 SPRITE,
75         } active_prog;
76
77 };
78
79 }
80
81 #endif