From 2295ac3544573cd230b31f2bd40877f594ed5a05 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 4 Dec 2022 11:27:14 +0100 Subject: 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. --- draw/box.cpp | 5 ++--- draw/quad-floor.cpp | 3 ++- draw/quad-wall-n.cpp | 4 ++-- draw/quad-wall-w.cpp | 4 ++-- draw/wireframe.cpp | 19 +++++++++++++++---- draw/wireframe.hpp | 2 ++ 6 files changed, 25 insertions(+), 12 deletions(-) (limited to 'draw') 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 -#include +#include "wireframe.hpp" #include 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 #include @@ -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 +#include "wireframe.hpp" #include 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 +#include "wireframe.hpp" #include 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 #include #include -#include -//#include +#include #include #include -//#include +#include +#include +#include #include namespace floormat::wireframe @@ -58,4 +59,14 @@ void mesh_base::set_subdata(ArrayView 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; -- cgit v1.2.3