summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-02 03:49:36 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-02 03:49:36 +0200
commitca152920deb5b62c355ffbd2fe8eb64afde5c097 (patch)
tree67910d8f4fc85833c0d307d88ac085050bead666
parent5193b9575d61d410a932f3f7b0662f01c4d8268b (diff)
a
-rw-r--r--floor-mesh.cpp10
-rw-r--r--floor-mesh.hpp3
-rw-r--r--main.cpp2
3 files changed, 8 insertions, 7 deletions
diff --git a/floor-mesh.cpp b/floor-mesh.cpp
index db8f076a..e129d7e1 100644
--- a/floor-mesh.cpp
+++ b/floor-mesh.cpp
@@ -9,7 +9,7 @@ namespace Magnum::Examples {
floor_mesh::floor_mesh()
{
- _floor_mesh.setCount((int)(quad_index_count * _index_data.size()))
+ _mesh.setCount((int)(quad_index_count * _index_data.size()))
.addVertexBuffer(_positions_buffer, 0, tile_shader::Position{})
.addVertexBuffer(_vertex_buffer, 0, tile_shader::TextureCoordinates{})
.setIndexBuffer(_index_buffer, 0, GL::MeshIndexType::UnsignedShort);
@@ -35,16 +35,16 @@ void floor_mesh::draw(tile_shader& shader, chunk& c)
_vertex_buffer.setData(_vertex_data, Magnum::GL::BufferUsage::DynamicDraw);
#if 1
- Magnum::GL::MeshView mesh{_floor_mesh};
+ Magnum::GL::MeshView mesh{ _mesh };
mesh.setCount(quad_index_count);
c.foreach_tile([&](tile& x, std::size_t i, local_coords) {
- mesh.setIndexRange((int)(i*quad_index_count));
+ mesh.setIndexRange((int)(i*quad_index_count), 0, quad_index_count*TILE_COUNT - 1);
x.ground_image.atlas->texture().bind(0);
shader.draw(mesh);
});
#else
- c[0].ground_image.atlas->texture().bind(0); // TODO
- shader.draw(_floor_mesh);
+ c[0].ground_image.atlas->texture().bind(0);
+ shader.draw(_mesh);
#endif
}
diff --git a/floor-mesh.hpp b/floor-mesh.hpp
index 0667c9e1..2dfdf5f3 100644
--- a/floor-mesh.hpp
+++ b/floor-mesh.hpp
@@ -34,9 +34,10 @@ private:
static const std::array<index_type, TILE_COUNT> _index_data;
static const std::array<vertex_positions_data, TILE_COUNT> _position_data;
+
+ GL::Mesh _mesh;
std::array<quad_data, TILE_COUNT> _vertex_data = {};
- GL::Mesh _floor_mesh;
GL::Buffer _vertex_buffer{_vertex_data, Magnum::GL::BufferUsage::DynamicDraw},
_index_buffer{_index_data, Magnum::GL::BufferUsage::StaticDraw},
_positions_buffer{_position_data, Magnum::GL::BufferUsage::StaticDraw};
diff --git a/main.cpp b/main.cpp
index 6b7fcac5..e701faa7 100644
--- a/main.cpp
+++ b/main.cpp
@@ -134,7 +134,7 @@ app::app(const Arguments& arguments):
k++;
}
- _floor_mesh.setCount((int)indices.size())
+ _mesh.setCount((int)indices.size())
.addVertexBuffer(GL::Buffer{vertices}, 0,
tile_shader::Position{}, tile_shader::TextureCoordinates{})
.addVertexBuffer(GL::Buffer{c.sampler_array()}, 0, tile_shader::TextureID{})