mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 04:05:57 +08:00
Tech ENABLE_GL_CORE_PROFILE - Use thick_lines shader where needed
This commit is contained in:
parent
a4baf6cb4f
commit
acbbe39bce
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// see as reference: https://github.com/mhalber/Lines/blob/master/geometry_shader_lines.h
|
// see as reference: https://github.com/mhalber/Lines/blob/master/geometry_shader_lines.h
|
||||||
|
|
||||||
const vec2 aa_radius = vec2(1.5);
|
const vec2 aa_radius = vec2(1.0);
|
||||||
|
|
||||||
uniform vec4 uniform_color;
|
uniform vec4 uniform_color;
|
||||||
|
|
@ -5,7 +5,7 @@
|
|||||||
layout(lines) in;
|
layout(lines) in;
|
||||||
layout(triangle_strip, max_vertices = 4) out;
|
layout(triangle_strip, max_vertices = 4) out;
|
||||||
|
|
||||||
const vec2 aa_radius = vec2(1.5);
|
const vec2 aa_radius = vec2(1.0);
|
||||||
|
|
||||||
uniform vec2 viewport_size;
|
uniform vec2 viewport_size;
|
||||||
uniform float width;
|
uniform float width;
|
||||||
@ -20,10 +20,10 @@ void main()
|
|||||||
float u_height = viewport_size[1];
|
float u_height = viewport_size[1];
|
||||||
float u_aspect_ratio = u_height / u_width;
|
float u_aspect_ratio = u_height / u_width;
|
||||||
|
|
||||||
vec2 ndc_a = gl_in[0].gl_Position.xy / gl_in[0].gl_Position.w;
|
vec2 ndc_0 = gl_in[0].gl_Position.xy / gl_in[0].gl_Position.w;
|
||||||
vec2 ndc_b = gl_in[1].gl_Position.xy / gl_in[1].gl_Position.w;
|
vec2 ndc_1 = gl_in[1].gl_Position.xy / gl_in[1].gl_Position.w;
|
||||||
|
|
||||||
vec2 line_vector = ndc_b - ndc_a;
|
vec2 line_vector = ndc_1 - ndc_0;
|
||||||
vec2 viewport_line_vector = line_vector * viewport_size;
|
vec2 viewport_line_vector = line_vector * viewport_size;
|
||||||
vec2 dir = normalize(viewport_line_vector);
|
vec2 dir = normalize(viewport_line_vector);
|
||||||
vec2 normal_dir = vec2(-dir.y, dir.x);
|
vec2 normal_dir = vec2(-dir.y, dir.x);
|
||||||
@ -38,19 +38,19 @@ void main()
|
|||||||
float half_line_length = line_length * 0.5;
|
float half_line_length = line_length * 0.5;
|
||||||
|
|
||||||
uv = vec2(-half_line_width, half_line_length);
|
uv = vec2(-half_line_width, half_line_length);
|
||||||
gl_Position = vec4((ndc_a + normal - extension) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw);
|
gl_Position = vec4((ndc_0 + normal - extension) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|
||||||
uv = vec2(-half_line_width, -half_line_length);
|
uv = vec2(-half_line_width, -half_line_length);
|
||||||
gl_Position = vec4((ndc_a - normal - extension) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw);
|
gl_Position = vec4((ndc_0 - normal - extension) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|
||||||
uv = vec2(half_line_width, half_line_length);
|
uv = vec2(half_line_width, half_line_length);
|
||||||
gl_Position = vec4((ndc_b + normal + extension) * gl_in[1].gl_Position.w, gl_in[1].gl_Position.zw);
|
gl_Position = vec4((ndc_1 + normal + extension) * gl_in[1].gl_Position.w, gl_in[1].gl_Position.zw);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|
||||||
uv = vec2(half_line_width, -half_line_length);
|
uv = vec2(half_line_width, -half_line_length);
|
||||||
gl_Position = vec4((ndc_b - normal + extension) * gl_in[1].gl_Position.w, gl_in[1].gl_Position.zw);
|
gl_Position = vec4((ndc_1 - normal + extension) * gl_in[1].gl_Position.w, gl_in[1].gl_Position.zw);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|
||||||
EndPrimitive();
|
EndPrimitive();
|
@ -403,7 +403,7 @@ void GLVolume::NonManifoldEdges::render()
|
|||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
const std::array<int, 4>& viewport = camera.get_viewport();
|
const std::array<int, 4>& viewport = camera.get_viewport();
|
||||||
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
|
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
|
||||||
shader->set_uniform("width", 1.5f);
|
shader->set_uniform("width", 0.5f);
|
||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#else
|
#else
|
||||||
glsafe(::glPushMatrix());
|
glsafe(::glPushMatrix());
|
||||||
@ -1094,7 +1094,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat");
|
GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat");
|
||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("lines_width");
|
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("thick_lines");
|
||||||
#else
|
#else
|
||||||
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat");
|
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat");
|
||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
|
@ -736,7 +736,7 @@ void GCodeViewer::init()
|
|||||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
buffer.vertices.format = VBuffer::EFormat::Position;
|
buffer.vertices.format = VBuffer::EFormat::Position;
|
||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
buffer.shader = "lines_width";
|
buffer.shader = "thick_lines";
|
||||||
#else
|
#else
|
||||||
buffer.shader = "flat";
|
buffer.shader = "flat";
|
||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
@ -3023,9 +3023,9 @@ void GCodeViewer::render_toolpaths()
|
|||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
const std::array<int, 4>& viewport = camera.get_viewport();
|
const std::array<int, 4>& viewport = camera.get_viewport();
|
||||||
const double zoom = camera.get_zoom();
|
const float zoom = float(camera.get_zoom());
|
||||||
shader.set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
|
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("width", (zoom < 5.0f) ? 0.5f : (0.5f + 5.0f * (zoom - 5.0f) / (100.0f - 5.0f)));
|
||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#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()));
|
glsafe(::glMultiDrawElements(GL_LINES, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_SHORT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
|
||||||
|
@ -6101,7 +6101,7 @@ void GLCanvas3D::_render_camera_target()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("lines_width");
|
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
|
||||||
#else
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
@ -6114,7 +6114,7 @@ void GLCanvas3D::_render_camera_target()
|
|||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
const std::array<int, 4>& viewport = camera.get_viewport();
|
const std::array<int, 4>& viewport = camera.get_viewport();
|
||||||
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
|
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
|
||||||
shader->set_uniform("width", 1.5f);
|
shader->set_uniform("width", 0.5f);
|
||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
@ -135,7 +135,11 @@ namespace GUI {
|
|||||||
#endif // !ENABLE_GL_CORE_PROFILE
|
#endif // !ENABLE_GL_CORE_PROFILE
|
||||||
|
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
|
||||||
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
@ -167,6 +171,11 @@ namespace GUI {
|
|||||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||||
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
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);
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
m_rectangle.set_color(ColorRGBA((m_state == EState::Select) ? 0.3f : 1.0f, (m_state == EState::Select) ? 1.0f : 0.3f, 0.3f, 1.0f));
|
m_rectangle.set_color(ColorRGBA((m_state == EState::Select) ? 0.3f : 1.0f, (m_state == EState::Select) ? 1.0f : 0.3f, 0.3f, 1.0f));
|
||||||
|
@ -46,7 +46,7 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||||||
valid &= append_shader("background", { prefix + "background.vs", prefix + "background.fs" });
|
valid &= append_shader("background", { prefix + "background.vs", prefix + "background.fs" });
|
||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
// used to render thick lines
|
// used to render thick lines
|
||||||
valid &= append_shader("lines_width", { prefix + "lines_width.vs", prefix + "lines_width.fs", prefix + "lines_width.gs" });
|
valid &= append_shader("thick_lines", { prefix + "thick_lines.vs", prefix + "thick_lines.fs", prefix + "thick_lines.gs" });
|
||||||
#endif // ENABLE_GL_CORE_PROFILE
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#else
|
#else
|
||||||
// basic shader, used to render all what was previously rendered using the immediate mode
|
// basic shader, used to render all what was previously rendered using the immediate mode
|
||||||
|
@ -107,15 +107,24 @@ void GLGizmoCut::on_render()
|
|||||||
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||||
|
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
const Vec3d diff = plane_center - m_old_center;
|
||||||
|
// Z changed when move with cut plane
|
||||||
|
// X and Y changed when move with cutted object
|
||||||
|
bool is_changed = std::abs(diff.x()) > EPSILON || std::abs(diff.y()) > EPSILON || std::abs(diff.z()) > EPSILON;
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
|
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
#if !ENABLE_GL_CORE_PROFILE
|
||||||
const Vec3d diff = plane_center - m_old_center;
|
const Vec3d diff = plane_center - m_old_center;
|
||||||
// Z changed when move with cut plane
|
// Z changed when move with cut plane
|
||||||
// X and Y changed when move with cutted object
|
// X and Y changed when move with cutted object
|
||||||
bool is_changed = std::abs(diff.x()) > EPSILON ||
|
bool is_changed = std::abs(diff.x()) > EPSILON ||
|
||||||
std::abs(diff.y()) > EPSILON ||
|
std::abs(diff.y()) > EPSILON ||
|
||||||
std::abs(diff.z()) > EPSILON;
|
std::abs(diff.z()) > EPSILON;
|
||||||
|
#endif // !ENABLE_GL_CORE_PROFILE
|
||||||
m_old_center = plane_center;
|
m_old_center = plane_center;
|
||||||
|
|
||||||
if (!m_plane.is_initialized() || is_changed) {
|
if (!m_plane.is_initialized() || is_changed) {
|
||||||
@ -123,7 +132,7 @@ void GLGizmoCut::on_render()
|
|||||||
|
|
||||||
GLModel::Geometry init_data;
|
GLModel::Geometry init_data;
|
||||||
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3 };
|
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3 };
|
||||||
init_data.color = { 0.8f, 0.8f, 0.8f, 0.5f };
|
init_data.color = { 0.8f, 0.8f, 0.8f, 0.5f };
|
||||||
init_data.reserve_vertices(4);
|
init_data.reserve_vertices(4);
|
||||||
init_data.reserve_indices(6);
|
init_data.reserve_indices(6);
|
||||||
|
|
||||||
@ -158,6 +167,22 @@ void GLGizmoCut::on_render()
|
|||||||
glsafe(::glEnd());
|
glsafe(::glEnd());
|
||||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
|
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
shader->stop_using();
|
||||||
|
}
|
||||||
|
|
||||||
|
shader = wxGetApp().get_shader("thick_lines");
|
||||||
|
if (shader != nullptr) {
|
||||||
|
shader->start_using();
|
||||||
|
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||||
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
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);
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
|
|
||||||
glsafe(::glEnable(GL_CULL_FACE));
|
glsafe(::glEnable(GL_CULL_FACE));
|
||||||
glsafe(::glDisable(GL_BLEND));
|
glsafe(::glDisable(GL_BLEND));
|
||||||
|
|
||||||
@ -192,6 +217,11 @@ void GLGizmoCut::on_render()
|
|||||||
|
|
||||||
m_grabber_connection.render();
|
m_grabber_connection.render();
|
||||||
|
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
shader->set_uniform("view_model_matrix", camera.get_view_matrix()* Geometry::assemble_transform(m_cut_contours.shift));
|
||||||
|
m_cut_contours.contours.render();
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
|
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +245,7 @@ void GLGizmoCut::on_render()
|
|||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_GL_CORE_PROFILE
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
shader = wxGetApp().get_shader("flat");
|
shader = wxGetApp().get_shader("flat");
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
@ -239,7 +270,8 @@ void GLGizmoCut::on_render()
|
|||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
}
|
#endif // !ENABLE_GL_CORE_PROFILE
|
||||||
|
}
|
||||||
|
|
||||||
void GLGizmoCut::on_render_for_picking()
|
void GLGizmoCut::on_render_for_picking()
|
||||||
{
|
{
|
||||||
|
@ -156,7 +156,11 @@ void GLGizmoMove3D::on_render()
|
|||||||
|
|
||||||
if (m_hover_id == -1) {
|
if (m_hover_id == -1) {
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
|
||||||
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
@ -165,6 +169,11 @@ void GLGizmoMove3D::on_render()
|
|||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
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);
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
// draw axes
|
// draw axes
|
||||||
@ -197,7 +206,11 @@ void GLGizmoMove3D::on_render()
|
|||||||
else {
|
else {
|
||||||
// draw axis
|
// draw axis
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
|
||||||
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
@ -205,6 +218,11 @@ void GLGizmoMove3D::on_render()
|
|||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
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);
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
render_grabber_connection(m_hover_id);
|
render_grabber_connection(m_hover_id);
|
||||||
|
@ -250,12 +250,21 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||||||
m_circle.init_from(std::move(init_data));
|
m_circle.init_from(std::move(init_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
|
||||||
|
#else
|
||||||
GLShaderProgram* shader = GUI::wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = GUI::wxGetApp().get_shader("flat");
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||||
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
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);
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
m_circle.render();
|
m_circle.render();
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
|
@ -174,7 +174,11 @@ void GLGizmoRotate::on_render()
|
|||||||
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
||||||
#endif // !ENABLE_GL_CORE_PROFILE
|
#endif // !ENABLE_GL_CORE_PROFILE
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
|
||||||
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
|
|
||||||
@ -183,12 +187,17 @@ void GLGizmoRotate::on_render()
|
|||||||
const Transform3d view_model_matrix = camera.get_view_matrix() * m_grabbers.front().matrix;
|
const Transform3d view_model_matrix = camera.get_view_matrix() * m_grabbers.front().matrix;
|
||||||
shader->set_uniform("view_model_matrix", view_model_matrix);
|
shader->set_uniform("view_model_matrix", view_model_matrix);
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
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);
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
const bool radius_changed = std::abs(m_old_radius - m_radius) > EPSILON;
|
const bool radius_changed = std::abs(m_old_radius - m_radius) > EPSILON;
|
||||||
m_old_radius = m_radius;
|
m_old_radius = m_radius;
|
||||||
|
|
||||||
ColorRGBA color((m_hover_id != -1) ? m_drag_color : m_highlight_color);
|
const ColorRGBA color = (m_hover_id != -1) ? m_drag_color : m_highlight_color;
|
||||||
render_circle(color, radius_changed);
|
render_circle(color, radius_changed);
|
||||||
if (m_hover_id != -1) {
|
if (m_hover_id != -1) {
|
||||||
const bool hover_radius_changed = std::abs(m_old_hover_radius - m_radius) > EPSILON;
|
const bool hover_radius_changed = std::abs(m_old_hover_radius - m_radius) > EPSILON;
|
||||||
|
@ -267,13 +267,22 @@ void GLGizmoScale3D::on_render()
|
|||||||
if (m_hover_id == -1) {
|
if (m_hover_id == -1) {
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
// draw connections
|
// draw connections
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
|
||||||
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
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);
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
if (m_grabbers[0].enabled && m_grabbers[1].enabled)
|
if (m_grabbers[0].enabled && m_grabbers[1].enabled)
|
||||||
render_grabbers_connection(0, 1, m_grabbers[0].color);
|
render_grabbers_connection(0, 1, m_grabbers[0].color);
|
||||||
@ -314,13 +323,22 @@ void GLGizmoScale3D::on_render()
|
|||||||
else if (m_hover_id == 0 || m_hover_id == 1) {
|
else if (m_hover_id == 0 || m_hover_id == 1) {
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
// draw connections
|
// draw connections
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
|
||||||
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
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);
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
render_grabbers_connection(0, 1, m_grabbers[0].color);
|
render_grabbers_connection(0, 1, m_grabbers[0].color);
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
@ -347,13 +365,22 @@ void GLGizmoScale3D::on_render()
|
|||||||
else if (m_hover_id == 2 || m_hover_id == 3) {
|
else if (m_hover_id == 2 || m_hover_id == 3) {
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
// draw connections
|
// draw connections
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
|
||||||
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
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);
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
render_grabbers_connection(2, 3, m_grabbers[2].color);
|
render_grabbers_connection(2, 3, m_grabbers[2].color);
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
@ -380,13 +407,22 @@ void GLGizmoScale3D::on_render()
|
|||||||
else if (m_hover_id == 4 || m_hover_id == 5) {
|
else if (m_hover_id == 4 || m_hover_id == 5) {
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
// draw connections
|
// draw connections
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
|
||||||
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
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);
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
render_grabbers_connection(4, 5, m_grabbers[4].color);
|
render_grabbers_connection(4, 5, m_grabbers[4].color);
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
@ -413,13 +449,22 @@ void GLGizmoScale3D::on_render()
|
|||||||
else if (m_hover_id >= 6) {
|
else if (m_hover_id >= 6) {
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
// draw connections
|
// draw connections
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
|
||||||
|
#else
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
if (shader != nullptr) {
|
if (shader != nullptr) {
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
|
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);
|
||||||
|
#endif // ENABLE_GL_CORE_PROFILE
|
||||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||||
render_grabbers_connection(6, 7, m_drag_color);
|
render_grabbers_connection(6, 7, m_drag_color);
|
||||||
render_grabbers_connection(7, 8, m_drag_color);
|
render_grabbers_connection(7, 8, m_drag_color);
|
||||||
|
@ -2011,7 +2011,7 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con
|
|||||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
#if ENABLE_GL_CORE_PROFILE
|
#if ENABLE_GL_CORE_PROFILE
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("lines_width");
|
GLShaderProgram* shader = wxGetApp().get_shader("thick_lines");
|
||||||
#else
|
#else
|
||||||
glsafe(::glLineWidth(2.0f * m_scale_factor));
|
glsafe(::glLineWidth(2.0f * m_scale_factor));
|
||||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user