]> git.localhorst.tv Git - gong.git/blob - src/graphics/Viewport.hpp
code, assets, and other stuff stolen from blank
[gong.git] / src / graphics / Viewport.hpp
1 #ifndef GONG_GRAPHICS_VIEWPORT_HPP_
2 #define GONG_GRAPHICS_VIEWPORT_HPP_
3
4 #include "align.hpp"
5 #include "BlendedSprite.hpp"
6 #include "Camera.hpp"
7 #include "Canvas.hpp"
8 #include "glm.hpp"
9 #include "PlainColor.hpp"
10 #include "SkyBoxShader.hpp"
11
12
13 namespace gong {
14 namespace graphics {
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);
25
26         void EnableDepthTest() noexcept;
27         void EqualDepthTest() 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         glm::vec2 GetPosition(const glm::vec2 &off, Gravity grav) const noexcept;
46
47         void SetCursor(const glm::vec3 &) noexcept;
48         void SetCursor(const glm::vec3 &, Gravity) noexcept;
49         void MoveCursor(const glm::vec3 &) noexcept;
50         const glm::mat4 &Cursor() const noexcept { return cursor; }
51
52         void OffsetCamera(const glm::vec3 &o) noexcept { cam_offset = o; }
53         const glm::vec3 &CameraOffset() const noexcept { return cam_offset; }
54
55         PlainColor &HUDColorProgram() noexcept;
56         SkyBoxShader &SkyBoxProgram() noexcept;
57         BlendedSprite &SpriteProgram() noexcept;
58
59         void WorldPosition(const glm::mat4 &) noexcept;
60
61         const glm::mat4 &Perspective() const noexcept { return cam.Projection(); }
62         const glm::mat4 &Ortho() const noexcept { return canv.Projection(); }
63
64 private:
65         Camera cam;
66         Canvas canv;
67
68         glm::mat4 cursor;
69
70         glm::vec3 cam_offset;
71
72         PlainColor color_prog;
73         SkyBoxShader sky_prog;
74         BlendedSprite sprite_prog;
75
76         enum {
77                 NONE,
78                 COLOR_HUD,
79                 SKY_BOX,
80                 SPRITE,
81         } active_prog;
82
83 };
84
85 }
86 }
87
88 #endif