23 const auto group = registry.group<GC>(entt::get<components::Transform>, entt::exclude<flags::Disabled>);
25 for (
auto&& [entity, gc, tf] : group.each())
27 graphics::RenderCommand cmd;
29 if constexpr ((std::is_same_v<GC, components::Circle>) || (std::is_same_v<GC, components::Ellipse>) || (std::is_same_v<GC, components::Point>) ||
30 (std::is_same_v<GC, components::Polygon>) || (std::is_same_v<GC, components::Polyline>))
32 graphics::Shape* shape = &gc.m_shape;
34 cmd.count = shape->vao().count();
35 cmd.instances = shape->vao().instances();
36 cmd.mode = shape->mode();
37 cmd.offset = shape->vao().offset();
38 cmd.vao = shape->vao().id();
40 cmd.uniforms.colour = shape->m_colour.vec4();
41 cmd.uniforms.entity =
static_cast<int>(entt::to_integral(entity));
42 cmd.uniforms.textured =
false;
43 cmd.uniforms.point = shape->mode() == GL_POINTS ? true :
false;
45 else if constexpr (std::is_same<GC, components::Sprite>::value)
47 cmd.count = gc.m_vao.count();
48 cmd.instances = gc.m_vao.instances();
49 cmd.mode = GL_TRIANGLES;
50 cmd.offset = gc.m_vao.offset();
51 cmd.vao = gc.m_vao.id();
52 cmd.texture = gc.get_texture()->id();
53 cmd.uniforms.colour = gc.m_tint.vec4();
54 cmd.uniforms.entity =
static_cast<int>(entt::to_integral(entity));
55 cmd.uniforms.textured =
true;
56 cmd.uniforms.point =
false;
58 else if constexpr (std::is_same<GC, components::Text>::value)
60 cmd.count = gc.m_text.vao().count();
61 cmd.instances = gc.m_text.vao().instances();
62 cmd.mode = GL_TRIANGLES;
63 cmd.offset = gc.m_text.vao().offset();
64 cmd.vao = gc.m_text.vao().id();
65 cmd.texture = gc.m_text.render_texture().texture();
66 cmd.uniforms.colour = gc.m_text.m_colour.vec4();
67 cmd.uniforms.entity =
static_cast<int>(entt::to_integral(entity));
68 cmd.uniforms.textured =
true;
69 cmd.uniforms.point =
false;
71 else if constexpr (std::is_same_v<GC, components::TileMap>)
73 cmd.count = gc.m_batch.vao().count();
75 cmd.layer = gc.m_render_layer;
76 cmd.mode = GL_TRIANGLES;
77 cmd.offset = gc.m_batch.vao().offset();
78 cmd.vao = gc.m_batch.vao().id();
79 cmd.texture = gc.get_texture()->id();
80 cmd.uniforms.colour = gc.m_tint;
81 cmd.uniforms.entity =
static_cast<int>(entt::to_integral(entity));
82 cmd.uniforms.textured =
true;
83 cmd.uniforms.point =
false;
86 cmd.uniforms.transform = tf.m_tf.get_transform();
87 graphics::Renderer::ref().submit_cmd(cmd);
String of glyphs rendered with a font.