summaryrefslogtreecommitdiffhomepage
path: root/draw
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-12-04 11:27:14 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-12-04 12:26:24 +0100
commit2295ac3544573cd230b31f2bd40877f594ed5a05 (patch)
tree9532408f3136d42b64a4e5b8fe628ce2cd2ca1e7 /draw
parent15198214ef081e1d59d4f0e13ad9ef6c6463885d (diff)
draw: fix warning on vmware dri backend
GL_LINE_WIDTH_RANGE returns [1, 10] so checking it in a driver-agnostic manner doesn't solve the problem.
Diffstat (limited to 'draw')
-rw-r--r--draw/box.cpp5
-rw-r--r--draw/quad-floor.cpp3
-rw-r--r--draw/quad-wall-n.cpp4
-rw-r--r--draw/quad-wall-w.cpp4
-rw-r--r--draw/wireframe.cpp19
-rw-r--r--draw/wireframe.hpp2
6 files changed, 25 insertions, 12 deletions
diff --git a/draw/box.cpp b/draw/box.cpp
index 18d6f861..2d44a3fd 100644
--- a/draw/box.cpp
+++ b/draw/box.cpp
@@ -1,6 +1,5 @@
#include "box.hpp"
-#include <array>
-#include <Magnum/Math/Vector3.h>
+#include "wireframe.hpp"
#include <Magnum/GL/Renderer.h>
namespace floormat::wireframe {
@@ -29,7 +28,7 @@ box::vertex_array box::make_vertex_array() const
void box::on_draw() const
{
- GL::Renderer::setLineWidth(line_width);
+ mesh_base::set_line_width(line_width);
}
box::index_array box::make_index_array()
diff --git a/draw/quad-floor.cpp b/draw/quad-floor.cpp
index 8d072a90..dd1b3bef 100644
--- a/draw/quad-floor.cpp
+++ b/draw/quad-floor.cpp
@@ -1,4 +1,5 @@
#include "quad-floor.hpp"
+#include "wireframe.hpp"
#include <array>
#include <Magnum/GL/Renderer.h>
@@ -22,7 +23,7 @@ quad_floor::quad_floor(Vector3 center, Vector2 size, float line_width) :
void quad_floor::on_draw() const
{
- GL::Renderer::setLineWidth(line_width);
+ mesh_base::set_line_width(line_width);
}
} // namespace floormat::wireframe
diff --git a/draw/quad-wall-n.cpp b/draw/quad-wall-n.cpp
index 2db11eb7..083f79ea 100644
--- a/draw/quad-wall-n.cpp
+++ b/draw/quad-wall-n.cpp
@@ -1,5 +1,5 @@
#include "quad-wall-n.hpp"
-#include <array>
+#include "wireframe.hpp"
#include <Magnum/GL/Renderer.h>
namespace floormat::wireframe {
@@ -22,7 +22,7 @@ quad_wall_n::quad_wall_n(Vector3 center, Vector3 size, float line_width) :
void quad_wall_n::on_draw() const
{
- GL::Renderer::setLineWidth(line_width);
+ mesh_base::set_line_width(line_width);
}
} // namespace floormat::wireframe
diff --git a/draw/quad-wall-w.cpp b/draw/quad-wall-w.cpp
index ad0e2ca0..898b602d 100644
--- a/draw/quad-wall-w.cpp
+++ b/draw/quad-wall-w.cpp
@@ -1,5 +1,5 @@
#include "quad-wall-w.hpp"
-#include <array>
+#include "wireframe.hpp"
#include <Magnum/GL/Renderer.h>
namespace floormat::wireframe {
@@ -22,7 +22,7 @@ quad_wall_w::quad_wall_w(Vector3 center, Vector3 size, float line_width) :
void quad_wall_w::on_draw() const
{
- GL::Renderer::setLineWidth(line_width);
+ mesh_base::set_line_width(line_width);
}
} // namespace floormat::wireframe
diff --git a/draw/wireframe.cpp b/draw/wireframe.cpp
index 2a41d5c2..7acebc70 100644
--- a/draw/wireframe.cpp
+++ b/draw/wireframe.cpp
@@ -1,13 +1,14 @@
+#include "compat/defs.hpp"
#include "wireframe.hpp"
#include "shaders/tile.hpp"
-//#include <Corrade/Containers/ArrayViewStl.h>
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/ArrayView.h>
-#include <Magnum/GL/TextureFormat.h>
-//#include <Magnum/ImageFlags.h>
+#include <Magnum/Math/Range.h>
#include <Magnum/ImageView.h>
#include <Magnum/PixelFormat.h>
-//#include <Magnum/PixelStorage.h>
+#include <Magnum/GL/Context.h>
+#include <Magnum/GL/Renderer.h>
+#include <Magnum/GL/TextureFormat.h>
#include <Magnum/Trade/ImageData.h>
namespace floormat::wireframe
@@ -58,4 +59,14 @@ void mesh_base::set_subdata(ArrayView<const void> array)
_vertex_buffer.setSubData(0, array);
}
+void mesh_base::set_line_width(float width)
+{
+ if (GL::Context::current().detectedDriver() == GL::Context::DetectedDriver::Svga3D)
+ return;
+
+ auto range = GL::Renderer::lineWidthRange();
+ if (range.contains(width))
+ GL::Renderer::setLineWidth(width);
+}
+
} // namespace floormat::wireframe
diff --git a/draw/wireframe.hpp b/draw/wireframe.hpp
index e0dd72cc..6d5249e1 100644
--- a/draw/wireframe.hpp
+++ b/draw/wireframe.hpp
@@ -24,6 +24,8 @@ concept traits = requires (const T& x) {
GL::Texture2D make_constant_texture();
struct mesh_base {
+ static void set_line_width(float width);
+
protected:
GL::Buffer _vertex_buffer{{}, GL::BufferUsage::DynamicDraw}, _constant_buffer, _index_buffer;
GL::Texture2D* _texture;