]> git.localhorst.tv Git - blobs.git/blob - src/graphics/Canvas.hpp
bc2a47af4b815d7fe6f9797499c3389a65b0caa6
[blobs.git] / src / graphics / Canvas.hpp
1 #ifndef BLOBS_GRAPHICS_CANVAS_HPP_
2 #define BLOBS_GRAPHICS_CANVAS_HPP_
3
4 #include "glm.hpp"
5 #include "Program.hpp"
6 #include "SimpleVAO.hpp"
7
8 #include <cstdint>
9
10
11 namespace blobs {
12 namespace graphics {
13
14 class Canvas {
15
16 public:
17         Canvas();
18         ~Canvas();
19
20         Canvas(const Canvas &) = delete;
21         Canvas &operator =(const Canvas &) = delete;
22
23         Canvas(Canvas &&) = delete;
24         Canvas &operator =(Canvas &&) = delete;
25
26 public:
27         void Resize(float w, float h) noexcept;
28         void ZIndex(float) noexcept;
29         void SetColor(const glm::vec4 &) noexcept;
30
31         void Activate() noexcept;
32         void DrawLine(const glm::vec2 &, const glm::vec2 &, float width = 1.0f);
33         void DrawRect(const glm::vec2 &, const glm::vec2 &, float width = 1.0f);
34         void FillRect(const glm::vec2 &, const glm::vec2 &);
35
36 private:
37         Program prog;
38         GLuint p_handle;
39         GLuint z_handle;
40         GLuint c_handle;
41
42         struct Attributes {
43                 glm::vec2 position;
44         };
45         SimpleVAO<Attributes, std::uint8_t> vao;
46
47 };
48
49 }
50 }
51
52 #endif