]> git.localhorst.tv Git - blank.git/blob - src/graphics/Viewport.hpp
sky box model & shader
[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         void SetCursor(const glm::vec3 &);
48         void SetCursor(const glm::vec3 &, Gravity);
49         void MoveCursor(const glm::vec3 &);
50         const glm::mat4 &Cursor() const noexcept { return cursor; }
51
52         BlockLighting &ChunkProgram() noexcept;
53         DirectionalLighting &EntityProgram() noexcept;
54         DirectionalLighting &HUDProgram() noexcept;
55         PlainColor &WorldOutlineProgram() noexcept;
56         PlainColor &HUDOutlineProgram() noexcept;
57         SkyBoxShader &SkyBoxProgram() noexcept;
58         BlendedSprite &SpriteProgram() noexcept;
59
60         void WorldPosition(const glm::mat4 &) noexcept;
61
62         const glm::mat4 &Perspective() const noexcept { return cam.Projection(); }
63         const glm::mat4 &Ortho() const noexcept { return canv.Projection(); }
64
65 private:
66         Camera cam;
67         Canvas canv;
68
69         glm::mat4 cursor;
70
71         BlockLighting chunk_prog;
72         DirectionalLighting entity_prog;
73         PlainColor outline_prog;
74         SkyBoxShader sky_prog;
75         BlendedSprite sprite_prog;
76
77         enum {
78                 NONE,
79                 CHUNK,
80                 ENTITY,
81                 HUD,
82                 OUTLINE_WORLD,
83                 OUTLINE_HUD,
84                 SKY_BOX,
85                 SPRITE,
86         } active_prog;
87
88 };
89
90 }
91
92 #endif