#pragma once #include "tile-atlas.hpp" #include "tile-defs.hpp" #include #include #include #include #include #include #include "Magnum/GL/RectangleTexture.h" namespace Magnum::Examples { struct tile_shader; namespace wireframe { template concept traits = requires (const T& x) { {T::num_vertices} -> std::convertible_to; {x.primitive} -> std::convertible_to; {x.make_vertex_array() } -> std::same_as>; }; struct null final { static constexpr auto primitive = GL::MeshPrimitive::Triangles; static constexpr std::size_t num_vertices = 0; static GL::RectangleTexture make_constant_texture(); static std::array make_vertex_array() { return {}; } }; struct quad final { quad(Vector3 center, Vector2 size); constexpr quad() = default; static constexpr std::size_t num_vertices = 4; static constexpr GL::MeshPrimitive primitive = GL::MeshPrimitive::LineLoop; using vertex_array = std::array; vertex_array make_vertex_array() const; private: Vector3 center = {}; Vector2 size = { TILE_SIZE[0], TILE_SIZE[1] }; }; } // namespace wireframe template struct wireframe_mesh final { wireframe_mesh(); void draw(tile_shader& shader, T traits); private: GL::Buffer _vertex_buffer{std::array{}}, _texcoords_buffer{std::array{}}; GL::RectangleTexture _texture = wireframe::null::make_constant_texture(); GL::Mesh _mesh; }; extern template struct wireframe_mesh; extern template struct wireframe_mesh; using wireframe_quad_mesh = wireframe_mesh; } // namespace Magnum::Examples