#pragma once #include "tile.hpp" #include #include #include #include #include #include namespace Magnum::Examples { struct tile_shader; struct chunk; struct wall_mesh final { wall_mesh(); void draw(tile_shader& shader, chunk& c); private: static constexpr auto COUNT1 = TILE_MAX_DIM*2, COUNT = COUNT1 * COUNT1; using texcoords_array = std::array; using position_array = std::array; struct vertex final { typename texcoords_array::value_type texcoords; }; using quad = std::array; using vertex_array = std::array; using texture_array = std::array; static void maybe_add_tile(vertex_array& data, texture_array& textures, tile& x, std::size_t pos); static void add_wall(vertex_array& data, texture_array& textures, tile_image& img, std::size_t pos); GL::Mesh _mesh; GL::Buffer _vertex_buffer{vertex_array{}, Magnum::GL::BufferUsage::DynamicDraw}, _index_buffer{make_index_array()}, _positions_buffer{make_position_array()}; static std::array, COUNT> make_index_array(); static std::array, COUNT> make_position_array(); }; } // namespace Magnum::Examples