From 89acc4653fe7ea3a76dd49711b3ac6b704ed509d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 6 Oct 2022 09:49:23 +0200 Subject: a --- src/wall-mesh.hpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/wall-mesh.hpp (limited to 'src/wall-mesh.hpp') diff --git a/src/wall-mesh.hpp b/src/wall-mesh.hpp new file mode 100644 index 00000000..ce1ff30a --- /dev/null +++ b/src/wall-mesh.hpp @@ -0,0 +1,47 @@ +#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 COUNT = TILE_MAX_DIM*2 * TILE_MAX_DIM*2; + + using texcoords_array = std::array; + using position_array = std::array; + + struct vertex final { + typename texcoords_array::value_type texcoords; + typename position_array::value_type position; + }; + + 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, std::size_t& pos, + tile& x, local_coords pt); + static void add_wall(vertex_array& data, texture_array& textures, std::size_t& pos, + tile_image& img, const position_array& positions); + + GL::Mesh _mesh; + GL::Buffer _vertex_buffer{vertex_array{}, Magnum::GL::BufferUsage::DynamicDraw}, + _index_buffer{make_index_array(), Magnum::GL::BufferUsage::StaticDraw}; + static std::array, COUNT> make_index_array(); +}; + +} // namespace Magnum::Examples -- cgit v1.2.3