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