From dcac3d7bd83c0cbdddae433e98598289bb1b06cd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 8 Oct 2022 22:47:54 +0200 Subject: a --- src/wireframe-mesh.cpp | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'src/wireframe-mesh.cpp') diff --git a/src/wireframe-mesh.cpp b/src/wireframe-mesh.cpp index 236f27ed..8d5d259f 100644 --- a/src/wireframe-mesh.cpp +++ b/src/wireframe-mesh.cpp @@ -7,15 +7,16 @@ #include #include -namespace Magnum::Examples::wireframe_traits { +namespace Magnum::Examples::wireframe +{ -GL::RectangleTexture wireframe_traits::null::make_constant_texture() +GL::RectangleTexture wireframe::null::make_constant_texture() { Trade::ImageData2D img{PixelFormat::RGBA8UI, {1, 1}, // NOLINT(misc-const-correctness) Containers::Array{Corrade::DirectInit, 4, (char)(unsigned char)255}}; GL::RectangleTexture tex; - tex.setWrapping(GL::SamplerWrapping::Repeat) + tex.setWrapping(GL::SamplerWrapping::ClampToEdge) .setMagnificationFilter(GL::SamplerFilter::Nearest) .setMinificationFilter(GL::SamplerFilter::Nearest) .setMaxAnisotropy(0) @@ -24,7 +25,7 @@ GL::RectangleTexture wireframe_traits::null::make_constant_texture() return tex; } -quad::vertex_array quad::make_vertex_positions_array() const +quad::vertex_array quad::make_vertex_array() const { constexpr auto X = TILE_SIZE[0], Y = TILE_SIZE[1]; constexpr float Z = 0; @@ -38,34 +39,28 @@ quad::vertex_array quad::make_vertex_positions_array() const quad::quad(Vector3 center, Vector2 size) : center(center), size(size) {} -} // namespace Magnum::Examples::wireframe_traits +} // namespace Magnum::Examples::wireframe namespace Magnum::Examples { -using wireframe_traits::traits; - -template wireframe_mesh::wireframe_mesh() +template wireframe_mesh::wireframe_mesh() { _mesh.setCount((int)T::num_vertices) .addVertexBuffer(_texcoords_buffer, 0, tile_shader::TextureCoordinates{}) - .addVertexBuffer(_positions_buffer, 0, tile_shader::Position{}); - if constexpr(T::num_indices > 0) - _mesh.setIndexBuffer(_index_buffer, 0, GL::MeshIndexType::UnsignedShort); - CORRADE_INTERNAL_ASSERT(T::num_indices > 0 == _mesh.isIndexed()); -}; + .addVertexBuffer(_vertex_buffer, 0, tile_shader::Position{}); + CORRADE_INTERNAL_ASSERT(!_mesh.isIndexed()); +} -template void wireframe_mesh::draw(tile_shader& shader, T x) +template void wireframe_mesh::draw(tile_shader& shader, T x) { GL::Renderer::setLineWidth(2); - _positions_buffer.setData(x.make_vertex_positions_array(), GL::BufferUsage::DynamicDraw); - if constexpr(T::num_indices > 0) - _index_buffer.setData(x.make_index_array(), GL::BufferUsage::DynamicDraw); + _vertex_buffer.setData(x.make_vertex_array(), GL::BufferUsage::DynamicDraw); _texture.bind(0); shader.draw(_mesh); } -template struct wireframe_mesh; -template struct wireframe_mesh; +template struct wireframe_mesh; +template struct wireframe_mesh; } // namespace Magnum::Examples -- cgit v1.2.3