From d109fa83bd9678fc3c9e21da48e90aa069ec1c7f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 13 Oct 2022 14:29:23 +0200 Subject: a --- draw/floor-mesh.cpp | 1 + draw/wall-mesh.cpp | 1 + draw/wireframe-mesh.cpp | 2 +- draw/wireframe-mesh.hpp | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) (limited to 'draw') diff --git a/draw/floor-mesh.cpp b/draw/floor-mesh.cpp index da8fe7f2..4c23a391 100644 --- a/draw/floor-mesh.cpp +++ b/draw/floor-mesh.cpp @@ -32,6 +32,7 @@ void floor_mesh::set_tile(quad_data& data, tile& x) void floor_mesh::draw(tile_shader& shader, chunk& c) { + _vertex_buffer.setData({nullptr, sizeof(quad_data) * TILE_COUNT}, Magnum::GL::BufferUsage::DynamicDraw); // orphan the buffer std::array data; for (auto& [x, idx, pt] : c) { set_tile(data[idx], x); diff --git a/draw/wall-mesh.cpp b/draw/wall-mesh.cpp index acd4ac75..81201598 100644 --- a/draw/wall-mesh.cpp +++ b/draw/wall-mesh.cpp @@ -39,6 +39,7 @@ void wall_mesh::maybe_add_tile(vertex_array& data, texture_array& textures, tile void wall_mesh::draw(tile_shader& shader, chunk& c) { + _vertex_buffer.setData({nullptr, sizeof(vertex_array)}, Magnum::GL::BufferUsage::DynamicDraw); // orphan the buffer texture_array textures = {}; { vertex_array data; diff --git a/draw/wireframe-mesh.cpp b/draw/wireframe-mesh.cpp index 32aa72aa..0b6846d7 100644 --- a/draw/wireframe-mesh.cpp +++ b/draw/wireframe-mesh.cpp @@ -29,7 +29,7 @@ GL::RectangleTexture mesh_base::make_constant_texture() mesh_base::mesh_base(GL::MeshPrimitive primitive, Containers::ArrayView index_data, std::size_t num_vertices, std::size_t num_indexes) : - _vertex_buffer{Containers::Array{ValueInit, num_vertices}}, + _vertex_buffer{Containers::Array{ValueInit, num_vertices}, GL::BufferUsage::DynamicDraw}, _texcoords_buffer{Containers::Array{ValueInit, num_vertices}}, _index_buffer{num_indexes == 0 ? GL::Buffer{NoCreate} : GL::Buffer{index_data}} { diff --git a/draw/wireframe-mesh.hpp b/draw/wireframe-mesh.hpp index 3c0deb37..6c1a7d3f 100644 --- a/draw/wireframe-mesh.hpp +++ b/draw/wireframe-mesh.hpp @@ -55,6 +55,7 @@ wireframe_mesh::wireframe_mesh() : template void wireframe_mesh::draw(tile_shader& shader, T x) { + _vertex_buffer.setData({nullptr, sizeof(Vector3) * T::num_vertices}, GL::BufferUsage::DynamicDraw); // orphan the buffer _vertex_buffer.setSubData(0, x.make_vertex_array()); x.on_draw(); mesh_base::draw(shader); -- cgit v1.2.3