summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-08 23:41:39 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-08 23:41:39 +0200
commit07d8adea58ec5b6b51704be1caf84012b0049313 (patch)
treed7f7571c766d0241b2e598a284ff5d396d9f66dc /src
parentdcac3d7bd83c0cbdddae433e98598289bb1b06cd (diff)
a
Diffstat (limited to 'src')
-rw-r--r--src/tile-atlas.cpp2
-rw-r--r--src/wireframe-mesh.cpp12
-rw-r--r--src/wireframe-mesh.hpp3
3 files changed, 10 insertions, 7 deletions
diff --git a/src/tile-atlas.cpp b/src/tile-atlas.cpp
index 917c60bc..95e01bfa 100644
--- a/src/tile-atlas.cpp
+++ b/src/tile-atlas.cpp
@@ -17,7 +17,7 @@ tile_atlas::tile_atlas(Containers::StringView name, const ImageView2D& image, Ve
tex_.setWrapping(GL::SamplerWrapping::ClampToEdge)
.setMagnificationFilter(GL::SamplerFilter::Nearest)
.setMinificationFilter(GL::SamplerFilter::Linear)
- .setMaxAnisotropy(0)
+ .setMaxAnisotropy(1)
.setStorage(GL::textureFormat(image.format()), image.size())
.setSubImage({}, image);
}
diff --git a/src/wireframe-mesh.cpp b/src/wireframe-mesh.cpp
index 8d5d259f..03378c02 100644
--- a/src/wireframe-mesh.cpp
+++ b/src/wireframe-mesh.cpp
@@ -5,21 +5,23 @@
#include <Magnum/GL/Renderer.h>
#include <Magnum/GL/TextureFormat.h>
#include <Magnum/PixelFormat.h>
+#include <Magnum/PixelStorage.h>
#include <Magnum/Trade/ImageData.h>
+#include <Magnum/ImageFlags.h>
namespace Magnum::Examples::wireframe
{
GL::RectangleTexture wireframe::null::make_constant_texture()
{
- Trade::ImageData2D img{PixelFormat::RGBA8UI, {1, 1}, // NOLINT(misc-const-correctness)
+ Trade::ImageData2D img{PixelStorage{}.setImageHeight(1).setRowLength(1),
+ PixelFormat::RGBA8UI, {1, 1},
Containers::Array<char>{Corrade::DirectInit, 4, (char)(unsigned char)255}};
-
GL::RectangleTexture tex;
tex.setWrapping(GL::SamplerWrapping::ClampToEdge)
.setMagnificationFilter(GL::SamplerFilter::Nearest)
.setMinificationFilter(GL::SamplerFilter::Nearest)
- .setMaxAnisotropy(0)
+ .setMaxAnisotropy(1)
.setStorage(GL::textureFormat(img.format()), img.size())
.setSubImage({}, std::move(img));
return tex;
@@ -29,12 +31,13 @@ quad::vertex_array quad::make_vertex_array() const
{
constexpr auto X = TILE_SIZE[0], Y = TILE_SIZE[1];
constexpr float Z = 0;
- return {{
+ vertex_array ret = {{
{ -X + center[0], -Y + center[1], Z + center[2] },
{ X + center[0], -Y + center[1], Z + center[2] },
{ X + center[0], Y + center[1], Z + center[2] },
{ -X + center[0], Y + center[1], Z + center[2] },
}};
+ return ret;
}
quad::quad(Vector3 center, Vector2 size) : center(center), size(size) {}
@@ -46,6 +49,7 @@ namespace Magnum::Examples {
template <wireframe::traits T> wireframe_mesh<T>::wireframe_mesh()
{
_mesh.setCount((int)T::num_vertices)
+ .setPrimitive(T::primitive)
.addVertexBuffer(_texcoords_buffer, 0, tile_shader::TextureCoordinates{})
.addVertexBuffer(_vertex_buffer, 0, tile_shader::Position{});
CORRADE_INTERNAL_ASSERT(!_mesh.isIndexed());
diff --git a/src/wireframe-mesh.hpp b/src/wireframe-mesh.hpp
index 855e673a..7a6892c2 100644
--- a/src/wireframe-mesh.hpp
+++ b/src/wireframe-mesh.hpp
@@ -24,7 +24,6 @@ concept traits = requires (const T& x) {
{x.make_vertex_array() } -> std::same_as<std::array<Vector3, T::num_vertices>>;
};
-
struct null final
{
static constexpr auto primitive = GL::MeshPrimitive::Triangles;
@@ -58,7 +57,7 @@ struct wireframe_mesh final
void draw(tile_shader& shader, T traits);
private:
- GL::Buffer _vertex_buffer{}, _texcoords_buffer{std::array<Vector2, T::num_vertices>{}};
+ GL::Buffer _vertex_buffer{std::array<Vector3, T::num_vertices>{}}, _texcoords_buffer{std::array<Vector2, T::num_vertices>{}};
GL::RectangleTexture _texture = wireframe::null::make_constant_texture();
GL::Mesh _mesh;
};