Tech ENABLE_GL_CORE_PROFILE - Thick lines shader enhanced to render dashed lines

Fixed conflicts while rebase with master
This commit is contained in:
enricoturri1966 2022-03-25 14:33:11 +01:00
parent 94305e5912
commit 914a66e2c3
17 changed files with 169 additions and 27 deletions

View file

@ -1,19 +1,25 @@
#version 150
// see as reference: https://github.com/mhalber/Lines/blob/master/geometry_shader_lines.h
// https://stackoverflow.com/questions/52928678/dashed-line-in-opengl3
const vec2 aa_radius = vec2(0.5);
uniform float dash_size;
uniform float gap_size;
uniform vec4 uniform_color;
in float line_width;
in float line_length;
in vec2 uv;
in vec3 uvs;
out vec4 out_color;
void main()
{
if (gap_size > 0.0 && fract(uvs.z / (dash_size + gap_size)) > dash_size / (dash_size + gap_size))
discard;
// We render a quad that is fattened by r, giving total width of the line to be w+r. We want smoothing to happen
// around w, so that the edge is properly smoothed out. As such, in the smoothstep function we have:
// Far edge : 1.0 = (w+r) / (w+r)
@ -21,7 +27,7 @@ void main()
// This way the smoothing is centered around 'w'.
out_color = uniform_color;
float au = 1.0 - smoothstep(1.0 - (2.0 * aa_radius[0] / line_width), 1.0, abs(uv.x / line_width));
float av = 1.0 - smoothstep(1.0 - (2.0 * aa_radius[1] / line_length), 1.0, abs(uv.y / line_length));
float au = 1.0 - smoothstep(1.0 - (2.0 * aa_radius[0] / line_width), 1.0, abs(uvs.x / line_width));
float av = 1.0 - smoothstep(1.0 - (2.0 * aa_radius[1] / line_length), 1.0, abs(uvs.y / line_length));
out_color.a *= min(av, au);
}

View file

@ -1,6 +1,7 @@
#version 150
// see as reference: https://github.com/mhalber/Lines/blob/master/geometry_shader_lines.h
// https://stackoverflow.com/questions/52928678/dashed-line-in-opengl3
layout(lines) in;
layout(triangle_strip, max_vertices = 4) out;
@ -10,9 +11,11 @@ const vec2 aa_radius = vec2(0.5);
uniform vec2 viewport_size;
uniform float width;
in float coord_s[];
out float line_width;
out float line_length;
out vec2 uv;
out vec3 uvs;
void main()
{
@ -35,19 +38,19 @@ void main()
float half_line_width = 0.5 * line_width;
float half_line_length = 0.5 * line_length;
uv = vec2(-half_line_width, half_line_length);
uvs = vec3(-half_line_width, half_line_length, coord_s[0]);
gl_Position = vec4((ndc_0 + normal - extension) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw);
EmitVertex();
uv = vec2(-half_line_width, -half_line_length);
uvs = vec3(-half_line_width, -half_line_length, coord_s[0]);
gl_Position = vec4((ndc_0 - normal - extension) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw);
EmitVertex();
uv = vec2(half_line_width, half_line_length);
uvs = vec3(half_line_width, half_line_length, coord_s[1]);
gl_Position = vec4((ndc_1 + normal + extension) * gl_in[1].gl_Position.w, gl_in[1].gl_Position.zw);
EmitVertex();
uv = vec2(half_line_width, -half_line_length);
uvs = vec3(half_line_width, -half_line_length, coord_s[1]);
gl_Position = vec4((ndc_1 - normal + extension) * gl_in[1].gl_Position.w, gl_in[1].gl_Position.zw);
EmitVertex();

View file

@ -1,13 +1,18 @@
#version 150
// see as reference: https://github.com/mhalber/Lines/blob/master/geometry_shader_lines.h
// https://stackoverflow.com/questions/52928678/dashed-line-in-opengl3
uniform mat4 view_model_matrix;
uniform mat4 projection_matrix;
in vec3 v_position;
// v_position.w = coordinate along the line
in vec4 v_position;
out float coord_s;
void main()
{
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
coord_s = v_position.w;
gl_Position = projection_matrix * view_model_matrix * vec4(v_position.xyz, 1.0);
}

View file

@ -48,6 +48,10 @@ using Vec2f = Eigen::Matrix<float, 2, 1, Eigen::DontAlign>;
using Vec3f = Eigen::Matrix<float, 3, 1, Eigen::DontAlign>;
using Vec2d = Eigen::Matrix<double, 2, 1, Eigen::DontAlign>;
using Vec3d = Eigen::Matrix<double, 3, 1, Eigen::DontAlign>;
#if ENABLE_GL_CORE_PROFILE
using Vec4f = Eigen::Matrix<float, 4, 1, Eigen::DontAlign>;
using Vec4d = Eigen::Matrix<double, 4, 1, Eigen::DontAlign>;
#endif // ENABLE_GL_CORE_PROFILE
using Points = std::vector<Point>;
using PointPtrs = std::vector<Point*>;

View file

@ -404,6 +404,7 @@ void GLVolume::NonManifoldEdges::render()
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.5f);
shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
#else
glsafe(::glPushMatrix());
@ -1094,7 +1095,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
#if ENABLE_LEGACY_OPENGL_REMOVAL
GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat");
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("thick_lines");
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("dashed_thick_lines");
#else
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE

View file

@ -736,7 +736,7 @@ void GCodeViewer::init()
#if ENABLE_GL_SHADERS_ATTRIBUTES
buffer.vertices.format = VBuffer::EFormat::Position;
#if ENABLE_GL_CORE_PROFILE
buffer.shader = "thick_lines";
buffer.shader = "dashed_thick_lines";
#else
buffer.shader = "flat";
#endif // ENABLE_GL_CORE_PROFILE
@ -3026,6 +3026,7 @@ void GCodeViewer::render_toolpaths()
const double zoom = camera.get_zoom();
shader.set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader.set_uniform("width", (zoom < 5.0) ? 1.0 : (1.0 + 5.0 * (zoom - 5.0) / (100.0 - 5.0)));
shader.set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glMultiDrawElements(GL_LINES, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_SHORT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));

View file

@ -6120,7 +6120,7 @@ void GLCanvas3D::_render_camera_target()
}
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
GLShaderProgram* shader = wxGetApp().get_shader("dashed_thick_lines");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
@ -6134,6 +6134,7 @@ void GLCanvas3D::_render_camera_target()
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 1.5f);
shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
for (int i = 0; i < 3; ++i) {

View file

@ -112,6 +112,17 @@ void GLModel::Geometry::add_vertex(const Vec3f& position, const Vec3f& normal)
vertices.emplace_back(normal.z());
}
#if ENABLE_GL_CORE_PROFILE
void GLModel::Geometry::add_vertex(const Vec4f& position)
{
assert(format.vertex_layout == EVertexLayout::P4);
vertices.emplace_back(position.x());
vertices.emplace_back(position.y());
vertices.emplace_back(position.z());
vertices.emplace_back(position.w());
}
#endif // ENABLE_GL_CORE_PROFILE
void GLModel::Geometry::add_index(unsigned int id)
{
indices.emplace_back(id);
@ -249,6 +260,9 @@ size_t GLModel::Geometry::vertex_stride_floats(const Format& format)
case EVertexLayout::P3: { return 3; }
case EVertexLayout::P3T2: { return 5; }
case EVertexLayout::P3N3: { return 6; }
#if ENABLE_GL_CORE_PROFILE
case EVertexLayout::P4: { return 4; }
#endif // ENABLE_GL_CORE_PROFILE
default: { assert(false); return 0; }
};
}
@ -262,6 +276,9 @@ size_t GLModel::Geometry::position_stride_floats(const Format& format)
case EVertexLayout::P3:
case EVertexLayout::P3T2:
case EVertexLayout::P3N3: { return 3; }
#if ENABLE_GL_CORE_PROFILE
case EVertexLayout::P4: { return 4; }
#endif // ENABLE_GL_CORE_PROFILE
default: { assert(false); return 0; }
};
}
@ -274,7 +291,12 @@ size_t GLModel::Geometry::position_offset_floats(const Format& format)
case EVertexLayout::P2T2:
case EVertexLayout::P3:
case EVertexLayout::P3T2:
#if ENABLE_GL_CORE_PROFILE
case EVertexLayout::P3N3:
case EVertexLayout::P4: { return 0; }
#else
case EVertexLayout::P3N3: { return 0; }
#endif // ENABLE_GL_CORE_PROFILE
default: { assert(false); return 0; }
};
}
@ -336,7 +358,12 @@ bool GLModel::Geometry::has_position(const Format& format)
case EVertexLayout::P2T2:
case EVertexLayout::P3:
case EVertexLayout::P3T2:
#if ENABLE_GL_CORE_PROFILE
case EVertexLayout::P3N3:
case EVertexLayout::P4: { return true; }
#else
case EVertexLayout::P3N3: { return true; }
#endif // ENABLE_GL_CORE_PROFILE
default: { assert(false); return false; }
};
}
@ -348,7 +375,12 @@ bool GLModel::Geometry::has_normal(const Format& format)
case EVertexLayout::P2:
case EVertexLayout::P2T2:
case EVertexLayout::P3:
#if ENABLE_GL_CORE_PROFILE
case EVertexLayout::P3T2:
case EVertexLayout::P4: { return false; }
#else
case EVertexLayout::P3T2: { return false; }
#endif // ENABLE_GL_CORE_PROFILE
case EVertexLayout::P3N3: { return true; }
default: { assert(false); return false; }
};
@ -362,7 +394,12 @@ bool GLModel::Geometry::has_tex_coord(const Format& format)
case EVertexLayout::P3T2: { return true; }
case EVertexLayout::P2:
case EVertexLayout::P3:
#if ENABLE_GL_CORE_PROFILE
case EVertexLayout::P3N3:
case EVertexLayout::P4: { return false; }
#else
case EVertexLayout::P3N3: { return false; }
#endif // ENABLE_GL_CORE_PROFILE
default: { assert(false); return false; }
};
}

View file

@ -63,6 +63,9 @@ namespace GUI {
P3, // position 3 floats
P3T2, // position 3 floats + texture coords 2 floats
P3N3, // position 3 floats + normal 3 floats
#if ENABLE_GL_CORE_PROFILE
P4, // position 4 floats
#endif // ENABLE_GL_CORE_PROFILE
};
enum class EIndexType : unsigned char
@ -92,6 +95,9 @@ namespace GUI {
void add_vertex(const Vec3f& position); // EVertexLayout::P3
void add_vertex(const Vec3f& position, const Vec2f& tex_coord); // EVertexLayout::P3T2
void add_vertex(const Vec3f& position, const Vec3f& normal); // EVertexLayout::P3N3
#if ENABLE_GL_CORE_PROFILE
void add_vertex(const Vec4f& position); // EVertexLayout::P4
#endif // ENABLE_GL_CORE_PROFILE
void set_vertex(size_t id, const Vec3f& position, const Vec3f& normal); // EVertexLayout::P3N3

View file

@ -136,7 +136,7 @@ namespace GUI {
#if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
GLShaderProgram* shader = wxGetApp().get_shader("dashed_thick_lines");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
@ -149,11 +149,44 @@ namespace GUI {
m_rectangle.reset();
GLModel::Geometry init_data;
#if ENABLE_GL_CORE_PROFILE
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P4 };
init_data.reserve_vertices(8);
init_data.reserve_indices(8);
#else
init_data.format = { GLModel::Geometry::EPrimitiveType::LineLoop, GLModel::Geometry::EVertexLayout::P2 };
init_data.reserve_vertices(4);
init_data.reserve_indices(4);
#endif // ENABLE_GL_CORE_PROFILE
// vertices
#if ENABLE_GL_CORE_PROFILE
const float width = right - left;
const float height = top - bottom;
float perimeter = 0.0f;
init_data.add_vertex(Vec4f(left, bottom, 0.0f, perimeter));
perimeter += width;
init_data.add_vertex(Vec4f(right, bottom, 0.0f, perimeter));
init_data.add_vertex(Vec4f(right, bottom, 0.0f, perimeter));
perimeter += height;
init_data.add_vertex(Vec4f(right, top, 0.0f, perimeter));
init_data.add_vertex(Vec4f(right, top, 0.0f, perimeter));
perimeter += width;
init_data.add_vertex(Vec4f(left, top, 0.0f, perimeter));
init_data.add_vertex(Vec4f(left, top, 0.0f, perimeter));
perimeter += height;
init_data.add_vertex(Vec4f(left, bottom, 0.0f, perimeter));
// indices
init_data.add_line(0, 1);
init_data.add_line(2, 3);
init_data.add_line(4, 5);
init_data.add_line(6, 7);
#else
init_data.add_vertex(Vec2f(left, bottom));
init_data.add_vertex(Vec2f(right, bottom));
init_data.add_vertex(Vec2f(right, top));
@ -164,6 +197,7 @@ namespace GUI {
init_data.add_index(1);
init_data.add_index(2);
init_data.add_index(3);
#endif // ENABLE_GL_CORE_PROFILE
m_rectangle.init_from(std::move(init_data));
}
@ -175,6 +209,8 @@ namespace GUI {
const std::array<int, 4>& viewport = wxGetApp().plater()->get_camera().get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f);
shader->set_uniform("dash_size", 0.01f);
shader->set_uniform("gap_size", 0.0075f);
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_GL_SHADERS_ATTRIBUTES

View file

@ -47,8 +47,8 @@ std::pair<bool, std::string> GLShadersManager::init()
// used to render 3D scene background
valid &= append_shader("background", { prefix + "background.vs", prefix + "background.fs" });
#if ENABLE_GL_CORE_PROFILE
// used to render thick lines
valid &= append_shader("thick_lines", { prefix + "thick_lines.vs", prefix + "thick_lines.fs", prefix + "thick_lines.gs" });
// used to render thick and/or dashed lines
valid &= append_shader("dashed_thick_lines", { prefix + "dashed_thick_lines.vs", prefix + "dashed_thick_lines.fs", prefix + "dashed_thick_lines.gs" });
#endif // ENABLE_GL_CORE_PROFILE
#else
// basic shader, used to render all what was previously rendered using the immediate mode

View file

@ -171,7 +171,7 @@ void GLGizmoCut::on_render()
shader->stop_using();
}
shader = wxGetApp().get_shader("thick_lines");
shader = wxGetApp().get_shader("dashed_thick_lines");
if (shader != nullptr) {
shader->start_using();
@ -181,6 +181,7 @@ void GLGizmoCut::on_render()
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.5f);
shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glEnable(GL_CULL_FACE));

View file

@ -167,7 +167,7 @@ void GLGizmoMove3D::on_render()
if (m_hover_id == -1) {
#if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
GLShaderProgram* shader = wxGetApp().get_shader("dashed_thick_lines");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
@ -183,6 +183,7 @@ void GLGizmoMove3D::on_render()
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
@ -219,7 +220,7 @@ void GLGizmoMove3D::on_render()
// draw axis
#if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
GLShaderProgram* shader = wxGetApp().get_shader("dashed_thick_lines");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
@ -234,6 +235,7 @@ void GLGizmoMove3D::on_render()
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.5f);
shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_GL_SHADERS_ATTRIBUTES

View file

@ -231,28 +231,58 @@ void GLGizmoPainterBase::render_cursor_circle()
GLModel::Geometry init_data;
static const unsigned int StepsCount = 32;
static const float StepSize = 2.0f * float(PI) / float(StepsCount);
#if ENABLE_GL_CORE_PROFILE
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P4 };
#else
init_data.format = { GLModel::Geometry::EPrimitiveType::LineLoop, GLModel::Geometry::EVertexLayout::P2 };
#endif // ENABLE_GL_CORE_PROFILE
init_data.color = { 0.0f, 1.0f, 0.3f, 1.0f };
#if ENABLE_GL_CORE_PROFILE
init_data.reserve_vertices(2 * StepsCount);
init_data.reserve_indices(2 * StepsCount);
#else
init_data.reserve_vertices(StepsCount);
init_data.reserve_indices(StepsCount);
#endif // ENABLE_GL_CORE_PROFILE
// vertices + indices
#if ENABLE_GL_CORE_PROFILE
float perimeter = 0.0f;
#endif // ENABLE_GL_CORE_PROFILE
for (unsigned int i = 0; i < StepsCount; ++i) {
#if !ENABLE_GL_CORE_PROFILE
const float angle = float(i) * StepSize;
#endif // !ENABLE_GL_CORE_PROFILE
#if ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_GL_CORE_PROFILE
const float angle_i = float(i) * StepSize;
const unsigned int j = (i + 1) % StepsCount;
const float angle_j = float(j) * StepSize;
const Vec2d v_i(2.0f * ((center.x() + ::cos(angle_i) * radius) * cnv_inv_width - 0.5f), -2.0f * ((center.y() + ::sin(angle_i) * radius) * cnv_inv_height - 0.5f));
const Vec2d v_j(2.0f * ((center.x() + ::cos(angle_j) * radius) * cnv_inv_width - 0.5f), -2.0f * ((center.y() + ::sin(angle_j) * radius) * cnv_inv_height - 0.5f));
init_data.add_vertex(Vec4f(v_i.x(), v_i.y(), 0.0f, perimeter));
perimeter += (v_j - v_i).norm();
init_data.add_vertex(Vec4f(v_j.x(), v_j.y(), 0.0f, perimeter));
#else
init_data.add_vertex(Vec2f(2.0f * ((center.x() + ::cos(angle) * radius) * cnv_inv_width - 0.5f),
-2.0f * ((center.y() + ::sin(angle) * radius) * cnv_inv_height - 0.5f)));
#endif // ENABLE_GL_CORE_PROFILE
#else
init_data.add_vertex(Vec2f(center.x() + ::cos(angle) * m_cursor_radius, center.y() + ::sin(angle) * m_cursor_radius));
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_GL_CORE_PROFILE
init_data.add_line(i * 2 + 0, i * 2 + 1);
#else
init_data.add_index(i);
#endif // ENABLE_GL_CORE_PROFILE
}
m_circle.init_from(std::move(init_data));
}
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
GLShaderProgram* shader = wxGetApp().get_shader("dashed_thick_lines");
#else
GLShaderProgram* shader = GUI::wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
@ -265,6 +295,8 @@ void GLGizmoPainterBase::render_cursor_circle()
const std::array<int, 4>& viewport = wxGetApp().plater()->get_camera().get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f);
shader->set_uniform("dash_size", 0.01f);
shader->set_uniform("gap_size", 0.0075f);
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_circle.render();

View file

@ -180,7 +180,7 @@ void GLGizmoRotate::on_render()
#endif // !ENABLE_GL_CORE_PROFILE
#if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
GLShaderProgram* shader = wxGetApp().get_shader("dashed_thick_lines");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
@ -196,6 +196,7 @@ void GLGizmoRotate::on_render()
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_GL_SHADERS_ATTRIBUTES

View file

@ -268,7 +268,7 @@ void GLGizmoScale3D::on_render()
#if ENABLE_LEGACY_OPENGL_REMOVAL
// draw connections
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
GLShaderProgram* shader = wxGetApp().get_shader("dashed_thick_lines");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
@ -282,6 +282,7 @@ void GLGizmoScale3D::on_render()
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (m_grabbers[0].enabled && m_grabbers[1].enabled)
@ -324,7 +325,7 @@ void GLGizmoScale3D::on_render()
#if ENABLE_LEGACY_OPENGL_REMOVAL
// draw connections
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
GLShaderProgram* shader = wxGetApp().get_shader("dashed_thick_lines");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
@ -338,6 +339,7 @@ void GLGizmoScale3D::on_render()
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
render_grabbers_connection(0, 1, m_grabbers[0].color);
@ -366,7 +368,7 @@ void GLGizmoScale3D::on_render()
#if ENABLE_LEGACY_OPENGL_REMOVAL
// draw connections
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
GLShaderProgram* shader = wxGetApp().get_shader("dashed_thick_lines");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
@ -380,6 +382,7 @@ void GLGizmoScale3D::on_render()
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
render_grabbers_connection(2, 3, m_grabbers[2].color);
@ -408,7 +411,7 @@ void GLGizmoScale3D::on_render()
#if ENABLE_LEGACY_OPENGL_REMOVAL
// draw connections
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
GLShaderProgram* shader = wxGetApp().get_shader("dashed_thick_lines");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
@ -422,6 +425,7 @@ void GLGizmoScale3D::on_render()
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
render_grabbers_connection(4, 5, m_grabbers[4].color);
@ -450,7 +454,7 @@ void GLGizmoScale3D::on_render()
#if ENABLE_LEGACY_OPENGL_REMOVAL
// draw connections
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
GLShaderProgram* shader = wxGetApp().get_shader("dashed_thick_lines");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_CORE_PROFILE
@ -464,6 +468,7 @@ void GLGizmoScale3D::on_render()
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 0.25f);
shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
render_grabbers_connection(6, 7, m_drag_color);

View file

@ -2014,7 +2014,7 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con
glsafe(::glEnable(GL_DEPTH_TEST));
#if ENABLE_GL_CORE_PROFILE
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
GLShaderProgram* shader = wxGetApp().get_shader("dashed_thick_lines");
#else
glsafe(::glLineWidth(2.0f * m_scale_factor));
GLShaderProgram* shader = wxGetApp().get_shader("flat");
@ -2031,6 +2031,7 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con
const std::array<int, 4>& viewport = camera.get_viewport();
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
shader->set_uniform("width", 1.5f);
shader->set_uniform("gap_size", 0.0f);
#endif // ENABLE_GL_CORE_PROFILE
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_box.set_color(to_rgba(color));