summaryrefslogtreecommitdiffhomepage
path: root/src/wireframe-mesh.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wireframe-mesh.cpp')
-rw-r--r--src/wireframe-mesh.cpp33
1 files changed, 14 insertions, 19 deletions
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 <Magnum/PixelFormat.h>
#include <Magnum/Trade/ImageData.h>
-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<char>{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 <traits T> wireframe_mesh<T>::wireframe_mesh()
+template <wireframe::traits T> wireframe_mesh<T>::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 <traits T> void wireframe_mesh<T>::draw(tile_shader& shader, T x)
+template <wireframe::traits T> void wireframe_mesh<T>::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<wireframe_traits::null>;
-template struct wireframe_mesh<wireframe_traits::quad>;
+template struct wireframe_mesh<wireframe::null>;
+template struct wireframe_mesh<wireframe::quad>;
} // namespace Magnum::Examples