mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 20:03:47 +00:00
Fix bed grid thin/thick lines in OpenGL Core Profile
This commit is contained in:
@@ -875,7 +875,30 @@ void PartPlate::render_exclude_area(bool force_default_color) {
|
|||||||
void PartPlate::render_grid(bool bottom) {
|
void PartPlate::render_grid(bool bottom) {
|
||||||
//glsafe(::glEnable(GL_MULTISAMPLE));
|
//glsafe(::glEnable(GL_MULTISAMPLE));
|
||||||
// draw grid
|
// draw grid
|
||||||
glsafe(::glLineWidth(1.0f * m_scale_factor));
|
|
||||||
|
// ORCA: OpenGL Core Profile support
|
||||||
|
// FIXME: ideally, we'd use the same shader for both the thin and thick lines, but for some reason setting the uniforms has no effect
|
||||||
|
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||||
|
if (shader == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
shader->start_using();
|
||||||
|
glsafe(::glEnable(GL_BLEND));
|
||||||
|
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||||
|
|
||||||
|
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
const std::array<int, 4>& viewport = camera.get_viewport();
|
||||||
|
const Transform3d& view_matrix = camera.get_view_matrix();
|
||||||
|
const Transform3d& projection_matrix = camera.get_projection_matrix();
|
||||||
|
|
||||||
|
shader->set_uniform("view_model_matrix", view_matrix);
|
||||||
|
shader->set_uniform("projection_matrix", projection_matrix);
|
||||||
|
|
||||||
|
#if !SLIC3R_OPENGL_ES
|
||||||
|
if (!OpenGLManager::get_gl_info().is_core_profile())
|
||||||
|
glsafe(::glLineWidth(1.0f * m_scale_factor));
|
||||||
|
#endif // !SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
ColorRGBA color;
|
ColorRGBA color;
|
||||||
if (bottom)
|
if (bottom)
|
||||||
@@ -889,9 +912,37 @@ void PartPlate::render_grid(bool bottom) {
|
|||||||
m_gridlines.set_color(color);
|
m_gridlines.set_color(color);
|
||||||
m_gridlines.render();
|
m_gridlines.render();
|
||||||
|
|
||||||
glsafe(::glLineWidth(2.0f * m_scale_factor));
|
shader->stop_using();
|
||||||
|
|
||||||
|
// ORCA: OpenGL Core Profile support
|
||||||
|
#if SLIC3R_OPENGL_ES
|
||||||
|
shader = wxGetApp().get_shader("dashed_lines");
|
||||||
|
#else
|
||||||
|
shader = OpenGLManager::get_gl_info().is_core_profile() ? wxGetApp().get_shader("dashed_thick_lines") : wxGetApp().get_shader("flat");
|
||||||
|
#endif // SLIC3R_OPENGL_ES
|
||||||
|
if (shader == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
shader->start_using();
|
||||||
|
|
||||||
|
shader->set_uniform("view_model_matrix", view_matrix);
|
||||||
|
shader->set_uniform("projection_matrix", projection_matrix);
|
||||||
|
|
||||||
|
#if !SLIC3R_OPENGL_ES
|
||||||
|
if (OpenGLManager::get_gl_info().is_core_profile()) {
|
||||||
|
#endif // !SLIC3R_OPENGL_ES
|
||||||
|
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
|
||||||
|
shader->set_uniform("width", 0.25f);
|
||||||
|
#if !SLIC3R_OPENGL_ES
|
||||||
|
} else {
|
||||||
|
glsafe(::glLineWidth(2.0f * m_scale_factor));
|
||||||
|
}
|
||||||
|
#endif // !SLIC3R_OPENGL_ES
|
||||||
|
|
||||||
m_gridlines_bolder.set_color(color);
|
m_gridlines_bolder.set_color(color);
|
||||||
m_gridlines_bolder.render();
|
m_gridlines_bolder.render();
|
||||||
|
|
||||||
|
shader->stop_using();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartPlate::render_height_limit(PartPlate::HeightLimitMode mode)
|
void PartPlate::render_height_limit(PartPlate::HeightLimitMode mode)
|
||||||
@@ -2757,9 +2808,6 @@ void PartPlate::render(const Transform3d& view_matrix, const Transform3d& projec
|
|||||||
render_exclude_area(force_background_color);
|
render_exclude_area(force_background_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_grid)
|
|
||||||
render_grid(bottom);
|
|
||||||
|
|
||||||
render_height_limit(mode);
|
render_height_limit(mode);
|
||||||
|
|
||||||
glsafe(::glDisable(GL_BLEND));
|
glsafe(::glDisable(GL_BLEND));
|
||||||
@@ -2771,6 +2819,9 @@ void PartPlate::render(const Transform3d& view_matrix, const Transform3d& projec
|
|||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (show_grid)
|
||||||
|
render_grid(bottom);
|
||||||
|
|
||||||
if (!bottom && m_selected && !force_background_color) {
|
if (!bottom && m_selected && !force_background_color) {
|
||||||
if (m_partplate_list)
|
if (m_partplate_list)
|
||||||
render_logo(bottom, m_partplate_list->render_cali_logo && render_cali);
|
render_logo(bottom, m_partplate_list->render_cali_logo && render_cali);
|
||||||
|
|||||||
Reference in New Issue
Block a user