-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshape_renderer.hpp.old
More file actions
59 lines (47 loc) · 2.15 KB
/
shape_renderer.hpp.old
File metadata and controls
59 lines (47 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include <gamecoe/entity/renderer/renderer.hpp>
#include <gamecoe/utils/shape.hpp>
#include <gamecoe/graphics/vertex_array.hpp>
#include <gamecoe/graphics/shader.hpp>
#include <gamecoe_config.hpp>
#include <colorcoe.hpp>
#include <memory>
#include <atomic>
#include <cstdint>
namespace gamecoe
{
class ShapeRenderer : public Renderer
{
private:
static std::atomic<std::uint32_t> s_counter;
static std::optional<Shader> s_shapeShader;
static std::optional<Shader> s_circleShader;
static std::optional<Shader> s_sphereShader;
Shape m_shape;
Color m_color;
const VertexArray &m_vertexArray;
std::optional<Shader> &shapeToShader(Shape shape) const;
ShapeRenderer(GameObject &owner, Shape shape, const Color &color, std::int8_t layer = 0);
virtual bool visible() const override;
virtual void renderImpl() const override;
public:
ShapeRenderer(const ShapeRenderer&) = delete;
ShapeRenderer& operator=(const ShapeRenderer&) = delete;
ShapeRenderer(ShapeRenderer&&) = delete;
ShapeRenderer& operator=(ShapeRenderer&&) = delete;
virtual ~ShapeRenderer() override;
virtual void initialize() override {}
virtual void begin() override {}
virtual void activate() override { m_active = true; }
virtual void deactivate() override { m_active = false; }
virtual void update() override {}
Shape shape() const;
Color color() const;
void setColor(const Color &color);
static std::unique_ptr<ShapeRenderer> triangle(GameObject &owner, const Color &color, std::int8_t layer = 0);
static std::unique_ptr<ShapeRenderer> rectangle(GameObject &owner, const Color &color, std::int8_t layer = 0);
static std::unique_ptr<ShapeRenderer> box(GameObject &owner, const Color &color, std::int8_t layer = 0);
static std::unique_ptr<ShapeRenderer> circle(GameObject &owner, const Color &color, std::int8_t layer = 0);
static std::unique_ptr<ShapeRenderer> sphere(GameObject &owner, const Color &color, std::int8_t layer = 0);
};
} // namespace gamecoe