diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-25 16:37:58 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-25 16:37:58 +0200 |
commit | f1df7c20129a1f1cc47c47e5731efd10f8e49aeb (patch) | |
tree | 0241e953981404e50a5c1fcd6d49f583ecf5995e /draw/wall.hpp | |
parent | a00ac8b5fed9d03cb2b3eafb4cd7d04546e341b1 (diff) |
rename in draw/
Diffstat (limited to 'draw/wall.hpp')
-rw-r--r-- | draw/wall.hpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/draw/wall.hpp b/draw/wall.hpp new file mode 100644 index 00000000..b021ef95 --- /dev/null +++ b/draw/wall.hpp @@ -0,0 +1,43 @@ +#pragma once + +#include "tile.hpp" +#include <array> +#include <Corrade/Containers/ArrayViewStl.h> +#include <Magnum/Math/Vector2.h> +#include <Magnum/Math/Vector3.h> +#include <Magnum/GL/Mesh.h> +#include <Magnum/GL/Buffer.h> + +namespace floormat { + +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; + + struct vertex final { + Vector2 texcoords; + }; + + using quad = std::array<vertex, 4>; + using vertex_array = std::array<quad, COUNT>; + using texture_array = std::array<GL::Texture2D*, COUNT>; + + 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<std::array<UnsignedShort, 6>, COUNT> make_index_array(); + static std::array<std::array<Vector3, 4>, COUNT> make_position_array(); +}; + +} // namespace floormat |