Merge branch 'et_gcode_viewer' of https://github.com/prusa3d/PrusaSlicer into et_gcode_viewer

This commit is contained in:
Enrico Turri 2020-05-22 16:50:26 +02:00
commit 1b0d1fd143
18 changed files with 106 additions and 1216 deletions

View file

@ -8,7 +8,7 @@ void main()
float sq_radius = pos.x * pos.x + pos.y * pos.y;
if (sq_radius > 0.25)
discard;
else if (sq_radius > 0.180625)
else if ((sq_radius < 0.005625) || (sq_radius > 0.180625))
gl_FragColor = vec4(0.5 * uniform_color, 1.0);
else
gl_FragColor = vec4(uniform_color, 1.0);

View file

@ -46,7 +46,4 @@
#define ENABLE_GCODE_VIEWER (1 && ENABLE_2_3_0_ALPHA1)
#define ENABLE_GCODE_VIEWER_STATISTICS (0 && ENABLE_GCODE_VIEWER)
// Enable the OpenGL shaders manager
#define ENABLE_SHADERS_MANAGER (1 && ENABLE_2_3_0_ALPHA1)
#endif // _prusaslicer_technologies_h_

View file

@ -163,14 +163,7 @@ Bed3D::Axes::~Axes()
void Bed3D::Axes::render() const
{
#if ENABLE_GCODE_VIEWER
#if ENABLE_SHADERS_MANAGER
auto render_axis = [this](const Transform3f& transform) {
#else
auto render_axis = [this](const Transform3f& transform, GLint color_id, const std::array<float, 4>& color) {
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)color.data()));
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glPushMatrix());
glsafe(::glMultMatrixf(transform.data()));
m_arrow.render();
@ -178,21 +171,13 @@ void Bed3D::Axes::render() const
};
m_arrow.init_from(stilized_arrow(16, DefaultTipRadius, DefaultTipLength, DefaultStemRadius, m_stem_length));
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
if (shader == nullptr)
return;
#else
if (!m_shader.init("gouraud_light.vs", "gouraud_light.fs"))
BOOST_LOG_TRIVIAL(error) << "Unable to initialize gouraud_light shader: please, check that the files gouraud_light.vs and gouraud_light.fs are available";
if (!m_shader.is_initialized())
return;
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glEnable(GL_DEPTH_TEST));
#if ENABLE_SHADERS_MANAGER
shader->start_using();
// x axis
@ -211,21 +196,6 @@ void Bed3D::Axes::render() const
render_axis(Geometry::assemble_transform(m_origin).cast<float>());
shader->stop_using();
#else
m_shader.start_using();
GLint color_id = ::glGetUniformLocation(m_shader.get_shader_program_id(), "uniform_color");
// x axis
render_axis(Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0f }).cast<float>(), color_id, { 0.75f, 0.0f, 0.0f, 1.0f });
// y axis
render_axis(Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0f }).cast<float>(), color_id, { 0.0f, 0.75f, 0.0f, 1.0f });
// z axis
render_axis(Geometry::assemble_transform(m_origin).cast<float>(), color_id, { 0.0f, 0.0f, 0.75f, 1.0f });
m_shader.stop_using();
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glDisable(GL_DEPTH_TEST));
#else
@ -571,23 +541,12 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const
if (m_triangles.get_vertices_count() > 0)
{
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* shader = wxGetApp().get_shader("printbed");
if (shader != nullptr)
{
shader->start_using();
shader->set_uniform("transparent_background", bottom);
shader->set_uniform("svg_source", boost::algorithm::iends_with(m_texture.get_source(), ".svg"));
#else
if (m_shader.get_shader_program_id() == 0)
m_shader.init("printbed.vs", "printbed.fs");
if (m_shader.is_initialized())
{
m_shader.start_using();
m_shader.set_uniform("transparent_background", bottom);
m_shader.set_uniform("svg_source", boost::algorithm::iends_with(m_texture.get_source(), ".svg"));
#endif // ENABLE_SHADERS_MANAGER
if (m_vbo_id == 0)
{
@ -608,13 +567,8 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const
unsigned int stride = m_triangles.get_vertex_data_size();
#if ENABLE_SHADERS_MANAGER
GLint position_id = shader->get_attrib_location("v_position");
GLint tex_coords_id = shader->get_attrib_location("v_tex_coords");
#else
GLint position_id = m_shader.get_attrib_location("v_position");
GLint tex_coords_id = m_shader.get_attrib_location("v_tex_coords");
#endif // ENABLE_SHADERS_MANAGER
// show the temporary texture while no compressed data is available
GLuint tex_id = (GLuint)m_temp_texture.get_id();
@ -652,11 +606,7 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const
glsafe(::glDisable(GL_BLEND));
glsafe(::glDepthMask(GL_TRUE));
#if ENABLE_SHADERS_MANAGER
shader->stop_using();
#else
m_shader.stop_using();
#endif // ENABLE_SHADERS_MANAGER
}
}
}
@ -679,7 +629,6 @@ void Bed3D::render_model() const
if (!m_model.get_filename().empty())
{
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
if (shader != nullptr)
{
@ -687,11 +636,6 @@ void Bed3D::render_model() const
m_model.render();
shader->stop_using();
}
#else
glsafe(::glEnable(GL_LIGHTING));
m_model.render();
glsafe(::glDisable(GL_LIGHTING));
#endif // ENABLE_SHADERS_MANAGER
}
}

View file

@ -3,9 +3,6 @@
#include "GLTexture.hpp"
#include "3DScene.hpp"
#if !ENABLE_SHADERS_MANAGER
#include "GLShader.hpp"
#endif // !ENABLE_SHADERS_MANAGER
#if ENABLE_GCODE_VIEWER
#include "GLModel.hpp"
#endif // ENABLE_GCODE_VIEWER
@ -71,9 +68,6 @@ class Bed3D
Vec3d m_origin{ Vec3d::Zero() };
float m_stem_length{ DefaultStemLength };
mutable GL_Model m_arrow;
#if !ENABLE_SHADERS_MANAGER
mutable Shader m_shader;
#endif // !ENABLE_SHADERS_MANAGER
public:
#else
@ -122,9 +116,6 @@ private:
mutable GLBed m_model;
// temporary texture shown until the main texture has still no levels compressed
mutable GLTexture m_temp_texture;
#if !ENABLE_SHADERS_MANAGER
mutable Shader m_shader;
#endif // !ENABLE_SHADERS_MANAGER
mutable unsigned int m_vbo_id;
Axes m_axes;

View file

@ -1,10 +1,8 @@
#include <GL/glew.h>
#include "3DScene.hpp"
#if ENABLE_SHADERS_MANAGER
#include "GLShader.hpp"
#include "GUI_App.hpp"
#endif // ENABLE_SHADERS_MANAGER
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/ExtrusionEntityCollection.hpp"
@ -644,11 +642,9 @@ GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCo
void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func) const
{
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
if (shader == nullptr)
return;
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glEnable(GL_BLEND));
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
@ -660,7 +656,6 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("print_box.min", m_print_box_min, 3);
shader->set_uniform("print_box.max", m_print_box_max, 3);
shader->set_uniform("z_range", m_z_range, 2);
@ -668,74 +663,16 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
#if ENABLE_SLOPE_RENDERING
shader->set_uniform("slope.z_range", m_slope.z_range);
#endif // ENABLE_SLOPE_RENDERING
#else
GLint current_program_id;
glsafe(::glGetIntegerv(GL_CURRENT_PROGRAM, &current_program_id));
GLint color_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "uniform_color") : -1;
GLint z_range_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "z_range") : -1;
GLint clipping_plane_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "clipping_plane") : -1;
GLint print_box_min_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.min") : -1;
GLint print_box_max_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.max") : -1;
GLint print_box_active_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.actived") : -1;
GLint print_box_worldmatrix_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "print_box.volume_world_matrix") : -1;
#if ENABLE_SLOPE_RENDERING
GLint slope_active_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "slope.actived") : -1;
GLint slope_normal_matrix_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "slope.volume_world_normal_matrix") : -1;
GLint slope_z_range_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "slope.z_range") : -1;
#endif // ENABLE_SLOPE_RENDERING
glcheck();
if (print_box_min_id != -1)
glsafe(::glUniform3fv(print_box_min_id, 1, (const GLfloat*)m_print_box_min));
if (print_box_max_id != -1)
glsafe(::glUniform3fv(print_box_max_id, 1, (const GLfloat*)m_print_box_max));
if (z_range_id != -1)
glsafe(::glUniform2fv(z_range_id, 1, (const GLfloat*)m_z_range));
if (clipping_plane_id != -1)
glsafe(::glUniform4fv(clipping_plane_id, 1, (const GLfloat*)m_clipping_plane));
#if ENABLE_SLOPE_RENDERING
if (slope_z_range_id != -1)
glsafe(::glUniform2fv(slope_z_range_id, 1, (const GLfloat*)m_slope.z_range.data()));
#endif // ENABLE_SLOPE_RENDERING
#endif // ENABLE_SHADERS_MANAGER
GLVolumeWithIdAndZList to_render = volumes_to_render(this->volumes, type, view_matrix, filter_func);
for (GLVolumeWithIdAndZ& volume : to_render) {
volume.first->set_render_color();
#if ENABLE_SLOPE_RENDERING
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("uniform_color", volume.first->render_color, 4);
shader->set_uniform("print_box.actived", volume.first->shader_outside_printer_detection_enabled);
shader->set_uniform("print_box.volume_world_matrix", volume.first->world_matrix());
shader->set_uniform("slope.actived", m_slope.active && !volume.first->is_modifier && !volume.first->is_wipe_tower);
shader->set_uniform("slope.volume_world_normal_matrix", volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast<float>());
#else
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)volume.first->render_color));
else
glsafe(::glColor4fv(volume.first->render_color));
if (print_box_active_id != -1)
glsafe(::glUniform1i(print_box_active_id, volume.first->shader_outside_printer_detection_enabled ? 1 : 0));
if (print_box_worldmatrix_id != -1)
glsafe(::glUniformMatrix4fv(print_box_worldmatrix_id, 1, GL_FALSE, (const GLfloat*)volume.first->world_matrix().cast<float>().data()));
if (slope_active_id != -1)
glsafe(::glUniform1i(slope_active_id, m_slope.active && !volume.first->is_modifier && !volume.first->is_wipe_tower ? 1 : 0));
if (slope_normal_matrix_id != -1)
{
Matrix3f normal_matrix = volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast<float>();
glsafe(::glUniformMatrix3fv(slope_normal_matrix_id, 1, GL_FALSE, (const GLfloat*)normal_matrix.data()));
}
#endif // ENABLE_SHADERS_MANAGER
volume.first->render();
#else
@ -1940,11 +1877,9 @@ void GLModel::reset()
void GLModel::render() const
{
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
if (shader == nullptr)
return;
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glEnable(GL_BLEND));
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
@ -1953,23 +1888,8 @@ void GLModel::render() const
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
#if !ENABLE_SHADERS_MANAGER
GLint current_program_id;
glsafe(::glGetIntegerv(GL_CURRENT_PROGRAM, &current_program_id));
GLint color_id = (current_program_id > 0) ? ::glGetUniformLocation(current_program_id, "uniform_color") : -1;
glcheck();
#endif // !ENABLE_SHADERS_MANAGER
#if ENABLE_SLOPE_RENDERING
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("uniform_color", m_volume.render_color, 4);
#else
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)m_volume.render_color));
else
glsafe(::glColor4fv(m_volume.render_color));
#endif // ENABLE_SHADERS_MANAGER
m_volume.render();
#else
m_volume.render(color_id, -1, -1);

View file

@ -107,18 +107,6 @@ void GCodeViewer::IBuffer::reset()
render_paths = std::vector<RenderPath>();
}
#if !ENABLE_SHADERS_MANAGER
bool GCodeViewer::IBuffer::init_shader(const std::string& vertex_shader_src, const std::string& fragment_shader_src)
{
if (!shader.init(vertex_shader_src, fragment_shader_src)) {
BOOST_LOG_TRIVIAL(error) << "Unable to initialize toolpaths shader: please, check that the files " << vertex_shader_src << " and " << fragment_shader_src << " are available";
return false;
}
return true;
}
#endif // !ENABLE_SHADERS_MANAGER
void GCodeViewer::IBuffer::add_path(const GCodeProcessor::MoveVertex& move, unsigned int i_id, unsigned int s_id)
{
Path::Endpoint endpoint = { i_id, s_id, move.position };
@ -151,9 +139,6 @@ GCodeViewer::Color GCodeViewer::Extrusions::Range::get_color_at(float value) con
void GCodeViewer::SequentialView::Marker::init()
{
m_model.init_from(stilized_arrow(16, 2.0f, 4.0f, 1.0f, 8.0f));
#if !ENABLE_SHADERS_MANAGER
init_shader();
#endif // !ENABLE_SHADERS_MANAGER
}
void GCodeViewer::SequentialView::Marker::set_world_position(const Vec3f& position)
@ -164,7 +149,6 @@ void GCodeViewer::SequentialView::Marker::set_world_position(const Vec3f& positi
void GCodeViewer::SequentialView::Marker::render() const
{
#if ENABLE_SHADERS_MANAGER
if (!m_visible)
return;
@ -177,18 +161,6 @@ void GCodeViewer::SequentialView::Marker::render() const
shader->start_using();
shader->set_uniform("uniform_color", m_color);
#else
if (!m_visible || !m_shader.is_initialized())
return;
glsafe(::glEnable(GL_BLEND));
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
m_shader.start_using();
GLint color_id = ::glGetUniformLocation(m_shader.get_shader_program_id(), "uniform_color");
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)m_color.data()));
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glPushMatrix());
glsafe(::glMultMatrixf(m_world_transform.data()));
@ -197,23 +169,11 @@ void GCodeViewer::SequentialView::Marker::render() const
glsafe(::glPopMatrix());
#if ENABLE_SHADERS_MANAGER
shader->stop_using();
#else
m_shader.stop_using();
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glDisable(GL_BLEND));
}
#if !ENABLE_SHADERS_MANAGER
void GCodeViewer::SequentialView::Marker::init_shader()
{
if (!m_shader.init("gouraud_light.vs", "gouraud_light.fs"))
BOOST_LOG_TRIVIAL(error) << "Unable to initialize gouraud_light shader: please, check that the files gouraud_light.vs and gouraud_light.fs are available";
}
#endif // !ENABLE_SHADERS_MANAGER
const std::vector<GCodeViewer::Color> GCodeViewer::Extrusion_Role_Colors {{
{ 0.50f, 0.50f, 0.50f }, // erNone
{ 1.00f, 1.00f, 0.40f }, // erPerimeter
@ -430,7 +390,6 @@ void GCodeViewer::set_layers_z_range(const std::array<double, 2>& layers_z_range
wxGetApp().plater()->update_preview_moves_slider();
}
#if ENABLE_SHADERS_MANAGER
void GCodeViewer::init_shaders()
{
unsigned char begin_id = buffer_id(GCodeProcessor::EMoveType::Retract);
@ -452,42 +411,6 @@ void GCodeViewer::init_shaders()
}
}
}
#else
bool GCodeViewer::init_shaders()
{
unsigned char begin_id = buffer_id(GCodeProcessor::EMoveType::Retract);
unsigned char end_id = buffer_id(GCodeProcessor::EMoveType::Count);
for (unsigned char i = begin_id; i < end_id; ++i)
{
std::string vertex_shader;
std::string fragment_shader;
switch (buffer_type(i))
{
case GCodeProcessor::EMoveType::Tool_change: { vertex_shader = "toolchanges.vs"; fragment_shader = "toolchanges.fs"; break; }
case GCodeProcessor::EMoveType::Color_change: { vertex_shader = "colorchanges.vs"; fragment_shader = "colorchanges.fs"; break; }
case GCodeProcessor::EMoveType::Pause_Print: { vertex_shader = "pauses.vs"; fragment_shader = "pauses.fs"; break; }
case GCodeProcessor::EMoveType::Custom_GCode: { vertex_shader = "customs.vs"; fragment_shader = "customs.fs"; break; }
case GCodeProcessor::EMoveType::Retract: { vertex_shader = "retractions.vs"; fragment_shader = "retractions.fs"; break; }
case GCodeProcessor::EMoveType::Unretract: { vertex_shader = "unretractions.vs"; fragment_shader = "unretractions.fs"; break; }
case GCodeProcessor::EMoveType::Extrude: { vertex_shader = "extrusions.vs"; fragment_shader = "extrusions.fs"; break; }
case GCodeProcessor::EMoveType::Travel: { vertex_shader = "travels.vs"; fragment_shader = "travels.fs"; break; }
default: { break; }
}
if (vertex_shader.empty() || fragment_shader.empty() || !m_buffers[i].init_shader(vertex_shader, fragment_shader))
return false;
}
if (!m_shells.shader.init("shells.vs", "shells.fs")) {
BOOST_LOG_TRIVIAL(error) << "Unable to initialize shells shader: please, check that the files shells.vs and shells.fs are available";
return false;
}
return true;
}
#endif // ENABLE_SHADERS_MANAGER
void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
{
@ -814,19 +737,6 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
void GCodeViewer::render_toolpaths() const
{
#if !ENABLE_SHADERS_MANAGER
auto set_color = [](GLint current_program_id, const Color& color) {
if (current_program_id > 0) {
GLint color_id = ::glGetUniformLocation(current_program_id, "uniform_color");
if (color_id >= 0) {
glsafe(::glUniform3fv(color_id, 1, (const GLfloat*)color.data()));
return;
}
}
BOOST_LOG_TRIVIAL(error) << "Unable to find uniform_color uniform";
};
#endif // !ENABLE_SHADERS_MANAGER
bool is_glsl_120 = wxGetApp().is_glsl_version_greater_or_equal_to(1, 20);
int detected_point_sizes[2];
::glGetIntegerv(GL_ALIASED_POINT_SIZE_RANGE, detected_point_sizes);
@ -851,28 +761,18 @@ void GCodeViewer::render_toolpaths() const
if (!buffer.visible)
continue;
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* shader = wxGetApp().get_shader(buffer.shader.c_str());
if (shader != nullptr) {
#else
if (buffer.shader.is_initialized()) {
#endif // ENABLE_SHADERS_MANAGER
shader->start_using();
GCodeProcessor::EMoveType type = buffer_type(i);
#if ENABLE_SHADERS_MANAGER
shader->start_using();
#else
buffer.shader.start_using();
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer.ibo_id));
switch (type)
{
case GCodeProcessor::EMoveType::Tool_change:
{
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("uniform_color", Options_Colors[static_cast<unsigned int>(EOptionsColors::ToolChanges)]);
shader->set_uniform("zoom", zoom);
shader->set_uniform("point_sizes", point_sizes);
@ -881,9 +781,6 @@ void GCodeViewer::render_toolpaths() const
glsafe(::glEnable(GL_POINT_SPRITE));
glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE));
}
#else
set_color(static_cast<GLint>(buffer.shader.get_shader_program_id()), Options_Colors[static_cast<unsigned int>(EOptionsColors::ToolChanges)]);
#endif // ENABLE_SHADERS_MANAGER
for (const RenderPath& path : buffer.render_paths)
{
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
@ -900,7 +797,6 @@ void GCodeViewer::render_toolpaths() const
}
case GCodeProcessor::EMoveType::Color_change:
{
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("uniform_color", Options_Colors[static_cast<unsigned int>(EOptionsColors::ColorChanges)]);
shader->set_uniform("zoom", zoom);
shader->set_uniform("point_sizes", point_sizes);
@ -909,9 +805,6 @@ void GCodeViewer::render_toolpaths() const
glsafe(::glEnable(GL_POINT_SPRITE));
glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE));
}
#else
set_color(static_cast<GLint>(buffer.shader.get_shader_program_id()), Options_Colors[static_cast<unsigned int>(EOptionsColors::ColorChanges)]);
#endif // ENABLE_SHADERS_MANAGER
for (const RenderPath& path : buffer.render_paths)
{
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
@ -928,7 +821,6 @@ void GCodeViewer::render_toolpaths() const
}
case GCodeProcessor::EMoveType::Pause_Print:
{
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("uniform_color", Options_Colors[static_cast<unsigned int>(EOptionsColors::PausePrints)]);
shader->set_uniform("zoom", zoom);
shader->set_uniform("point_sizes", point_sizes);
@ -937,9 +829,6 @@ void GCodeViewer::render_toolpaths() const
glsafe(::glEnable(GL_POINT_SPRITE));
glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE));
}
#else
set_color(static_cast<GLint>(buffer.shader.get_shader_program_id()), Options_Colors[static_cast<unsigned int>(EOptionsColors::PausePrints)]);
#endif // ENABLE_SHADERS_MANAGER
for (const RenderPath& path : buffer.render_paths)
{
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
@ -956,7 +845,6 @@ void GCodeViewer::render_toolpaths() const
}
case GCodeProcessor::EMoveType::Custom_GCode:
{
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("uniform_color", Options_Colors[static_cast<unsigned int>(EOptionsColors::CustomGCodes)]);
shader->set_uniform("zoom", zoom);
shader->set_uniform("point_sizes", point_sizes);
@ -965,9 +853,6 @@ void GCodeViewer::render_toolpaths() const
glsafe(::glEnable(GL_POINT_SPRITE));
glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE));
}
#else
set_color(static_cast<GLint>(buffer.shader.get_shader_program_id()), Options_Colors[static_cast<unsigned int>(EOptionsColors::CustomGCodes)]);
#endif // ENABLE_SHADERS_MANAGER
for (const RenderPath& path : buffer.render_paths)
{
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
@ -984,7 +869,6 @@ void GCodeViewer::render_toolpaths() const
}
case GCodeProcessor::EMoveType::Retract:
{
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("uniform_color", Options_Colors[static_cast<unsigned int>(EOptionsColors::Retractions)]);
shader->set_uniform("zoom", zoom);
shader->set_uniform("point_sizes", point_sizes);
@ -993,9 +877,6 @@ void GCodeViewer::render_toolpaths() const
glsafe(::glEnable(GL_POINT_SPRITE));
glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE));
}
#else
set_color(static_cast<GLint>(buffer.shader.get_shader_program_id()), Options_Colors[static_cast<unsigned int>(EOptionsColors::Retractions)]);
#endif // ENABLE_SHADERS_MANAGER
for (const RenderPath& path : buffer.render_paths)
{
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
@ -1012,7 +893,6 @@ void GCodeViewer::render_toolpaths() const
}
case GCodeProcessor::EMoveType::Unretract:
{
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("uniform_color", Options_Colors[static_cast<unsigned int>(EOptionsColors::Unretractions)]);
shader->set_uniform("zoom", zoom);
shader->set_uniform("point_sizes", point_sizes);
@ -1021,9 +901,6 @@ void GCodeViewer::render_toolpaths() const
glsafe(::glEnable(GL_POINT_SPRITE));
glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE));
}
#else
set_color(static_cast<GLint>(buffer.shader.get_shader_program_id()), Options_Colors[static_cast<unsigned int>(EOptionsColors::Unretractions)]);
#endif // ENABLE_SHADERS_MANAGER
for (const RenderPath& path : buffer.render_paths)
{
glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
@ -1042,11 +919,7 @@ void GCodeViewer::render_toolpaths() const
{
for (const RenderPath& path : buffer.render_paths)
{
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("uniform_color", path.color);
#else
set_color(static_cast<GLint>(buffer.shader.get_shader_program_id()), path.color);
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glMultiDrawElements(GL_LINE_STRIP, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
#if ENABLE_GCODE_VIEWER_STATISTICS
++m_statistics.gl_multi_line_strip_calls_count;
@ -1059,11 +932,7 @@ void GCodeViewer::render_toolpaths() const
{
for (const RenderPath& path : buffer.render_paths)
{
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("uniform_color", path.color);
#else
set_color(static_cast<GLint>(buffer.shader.get_shader_program_id()), path.color);
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glMultiDrawElements(GL_LINE_STRIP, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size()));
#if ENABLE_GCODE_VIEWER_STATISTICS
++m_statistics.gl_multi_line_strip_calls_count;
@ -1075,11 +944,7 @@ void GCodeViewer::render_toolpaths() const
}
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
#if ENABLE_SHADERS_MANAGER
shader->stop_using();
#else
buffer.shader.stop_using();
#endif // ENABLE_SHADERS_MANAGER
}
}
@ -1089,7 +954,6 @@ void GCodeViewer::render_toolpaths() const
void GCodeViewer::render_shells() const
{
#if ENABLE_SHADERS_MANAGER
if (!m_shells.visible || m_shells.volumes.empty())
return;
@ -1104,18 +968,6 @@ void GCodeViewer::render_shells() const
shader->stop_using();
// glsafe(::glDepthMask(GL_TRUE));
#else
if (!m_shells.visible || m_shells.volumes.empty() || !m_shells.shader.is_initialized())
return;
// glsafe(::glDepthMask(GL_FALSE));
m_shells.shader.start_using();
m_shells.volumes.render(GLVolumeCollection::Transparent, true, wxGetApp().plater()->get_camera().get_view_matrix());
m_shells.shader.stop_using();
// glsafe(::glDepthMask(GL_TRUE));
#endif // ENABLE_SHADERS_MANAGER
}
void GCodeViewer::render_legend() const
@ -1135,12 +987,43 @@ void GCodeViewer::render_legend() const
ImDrawList* draw_list = ImGui::GetWindowDrawList();
auto add_item = [draw_list, &imgui](const Color& color, const std::string& label, std::function<void()> callback = nullptr) {
enum class EItemType : unsigned char
{
Rect,
Circle,
Line
};
auto add_item = [draw_list, &imgui](EItemType type, const Color& color, const std::string& label, std::function<void()> callback = nullptr) {
float icon_size = ImGui::GetTextLineHeight();
ImVec2 pos = ImGui::GetCursorPos();
draw_list->AddRect({ pos.x, pos.y }, { pos.x + icon_size, pos.y + icon_size }, ICON_BORDER_COLOR, 0.0f, 0);
draw_list->AddRectFilled({ pos.x + 1.0f, pos.y + 1.0f }, { pos.x + icon_size - 1.0f, pos.y + icon_size - 1.0f },
ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }));
switch (type)
{
default:
case EItemType::Rect:
{
draw_list->AddRect({ pos.x, pos.y }, { pos.x + icon_size, pos.y + icon_size }, ICON_BORDER_COLOR, 0.0f, 0);
draw_list->AddRectFilled({ pos.x + 1.0f, pos.y + 1.0f }, { pos.x + icon_size - 1.0f, pos.y + icon_size - 1.0f },
ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }));
break;
}
case EItemType::Circle:
{
draw_list->AddCircle({ 0.5f * (pos.x + pos.x + icon_size), 0.5f * (pos.y + pos.y + icon_size) }, 0.5f * icon_size, ICON_BORDER_COLOR, 16);
draw_list->AddCircleFilled({ 0.5f * (pos.x + pos.x + icon_size), 0.5f * (pos.y + pos.y + icon_size) }, (0.5f * icon_size) - 2.0f,
ImGui::GetColorU32({ 0.5f * color[0], 0.5f * color[1], 0.5f * color[2], 1.0f }), 16);
draw_list->AddCircleFilled({ 0.5f * (pos.x + pos.x + icon_size), 0.5f * (pos.y + pos.y + icon_size) }, (0.5f * icon_size) - 3.0f,
ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }), 16);
draw_list->AddCircleFilled({ 0.5f * (pos.x + pos.x + icon_size), 0.5f * (pos.y + pos.y + icon_size) }, 1.5f,
ImGui::GetColorU32({ 0.5f * color[0], 0.5f * color[1], 0.5f * color[2], 1.0f }), 16);
break;
}
case EItemType::Line:
{
draw_list->AddLine({ pos.x + 1, pos.y + icon_size - 1}, { pos.x + icon_size - 1, pos.y + 1 }, ImGui::GetColorU32({ color[0], color[1], color[2], 1.0f }), 3.0f);
break;
}
}
// draw text
ImGui::Dummy({ icon_size, icon_size });
@ -1158,7 +1041,7 @@ void GCodeViewer::render_legend() const
auto add_range_item = [this, draw_list, &imgui, add_item](int i, float value, unsigned int decimals) {
char buf[1024];
::sprintf(buf, "%.*f", decimals, value);
add_item(Range_Colors[i], buf);
add_item(EItemType::Rect, Range_Colors[i], buf);
};
float step_size = range.step_size();
@ -1200,7 +1083,7 @@ void GCodeViewer::render_legend() const
if (!visible)
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.3333f);
add_item(Extrusion_Role_Colors[static_cast<unsigned int>(role)], _u8L(ExtrusionEntity::role_to_string(role)), [this, role]() {
add_item(EItemType::Rect, Extrusion_Role_Colors[static_cast<unsigned int>(role)], _u8L(ExtrusionEntity::role_to_string(role)), [this, role]() {
if (role < erCount)
{
m_extrusions.role_visibility_flags = is_visible(role) ? m_extrusions.role_visibility_flags & ~(1 << role) : m_extrusions.role_visibility_flags | (1 << role);
@ -1230,7 +1113,7 @@ void GCodeViewer::render_legend() const
if (it == m_extruder_ids.end())
continue;
add_item(m_tool_colors[i], (boost::format(_u8L("Extruder %d")) % (i + 1)).str());
add_item(EItemType::Rect, m_tool_colors[i], (boost::format(_u8L("Extruder %d")) % (i + 1)).str());
}
break;
}
@ -1241,7 +1124,7 @@ void GCodeViewer::render_legend() const
if (extruders_count == 1) { // single extruder use case
if (custom_gcode_per_print_z.empty())
// no data to show
add_item(m_tool_colors.front(), _u8L("Default print color"));
add_item(EItemType::Rect, m_tool_colors.front(), _u8L("Default print color"));
else {
std::vector<std::pair<double, double>> cp_values;
cp_values.reserve(custom_gcode_per_print_z.size());
@ -1265,7 +1148,7 @@ void GCodeViewer::render_legend() const
const int items_cnt = static_cast<int>(cp_values.size());
if (items_cnt == 0) { // There is no one color change, but there are some pause print or custom Gcode
add_item(m_tool_colors.front(), _u8L("Default print color"));
add_item(EItemType::Rect, m_tool_colors.front(), _u8L("Default print color"));
}
else {
for (int i = items_cnt; i >= 0; --i) {
@ -1273,14 +1156,14 @@ void GCodeViewer::render_legend() const
std::string id_str = " (" + std::to_string(i + 1) + ")";
if (i == 0) {
add_item(m_tool_colors[i], (boost::format(_u8L("up to %.2f mm")) % cp_values.front().first).str() + id_str);
add_item(EItemType::Rect, m_tool_colors[i], (boost::format(_u8L("up to %.2f mm")) % cp_values.front().first).str() + id_str);
break;
}
else if (i == items_cnt) {
add_item(m_tool_colors[i], (boost::format(_u8L("above %.2f mm")) % cp_values[i - 1].second).str() + id_str);
add_item(EItemType::Rect, m_tool_colors[i], (boost::format(_u8L("above %.2f mm")) % cp_values[i - 1].second).str() + id_str);
continue;
}
add_item(m_tool_colors[i], (boost::format(_u8L("%.2f - %.2f mm")) % cp_values[i - 1].second% cp_values[i].first).str() + id_str);
add_item(EItemType::Rect, m_tool_colors[i], (boost::format(_u8L("%.2f - %.2f mm")) % cp_values[i - 1].second% cp_values[i].first).str() + id_str);
}
}
}
@ -1289,7 +1172,7 @@ void GCodeViewer::render_legend() const
{
// extruders
for (unsigned int i = 0; i < (unsigned int)extruders_count; ++i) {
add_item(m_tool_colors[i], (boost::format(_u8L("Extruder %d")) % (i + 1)).str());
add_item(EItemType::Rect, m_tool_colors[i], (boost::format(_u8L("Extruder %d")) % (i + 1)).str());
}
// color changes
@ -1300,7 +1183,7 @@ void GCodeViewer::render_legend() const
// create label for color change item
std::string id_str = " (" + std::to_string(color_change_idx--) + ")";
add_item(m_tool_colors[last_color_id--],
add_item(EItemType::Rect, m_tool_colors[last_color_id--],
(boost::format(_u8L("Color change for Extruder %d at %.2f mm")) % custom_gcode_per_print_z[i].extruder % custom_gcode_per_print_z[i].print_z).str() + id_str);
}
}
@ -1333,9 +1216,9 @@ void GCodeViewer::render_legend() const
ImGui::Separator();
// items
add_item(Travel_Colors[0], _u8L("Movement"));
add_item(Travel_Colors[1], _u8L("Extrusion"));
add_item(Travel_Colors[2], _u8L("Retraction"));
add_item(EItemType::Line, Travel_Colors[0], _u8L("Movement"));
add_item(EItemType::Line, Travel_Colors[1], _u8L("Extrusion"));
add_item(EItemType::Line, Travel_Colors[2], _u8L("Retraction"));
break;
}
@ -1354,7 +1237,7 @@ void GCodeViewer::render_legend() const
auto add_option = [this, add_item](GCodeProcessor::EMoveType move_type, EOptionsColors color, const std::string& text) {
const IBuffer& buffer = m_buffers[buffer_id(move_type)];
if (buffer.visible && buffer.indices_count > 0)
add_item(Options_Colors[static_cast<unsigned int>(color)], text);
add_item(EItemType::Circle, Options_Colors[static_cast<unsigned int>(color)], text);
};
// options

View file

@ -2,9 +2,6 @@
#define slic3r_GCodeViewer_hpp_
#if ENABLE_GCODE_VIEWER
#if !ENABLE_SHADERS_MANAGER
#include "GLShader.hpp"
#endif // !ENABLE_SHADERS_MANAGER
#include "3DScene.hpp"
#include "libslic3r/GCode/GCodeProcessor.hpp"
#include "GLModel.hpp"
@ -91,19 +88,12 @@ class GCodeViewer
{
unsigned int ibo_id{ 0 };
size_t indices_count{ 0 };
#if ENABLE_SHADERS_MANAGER
std::string shader;
#else
Shader shader;
#endif // ENABLE_SHADERS_MANAGER
std::vector<Path> paths;
std::vector<RenderPath> render_paths;
bool visible{ false };
void reset();
#if !ENABLE_SHADERS_MANAGER
bool init_shader(const std::string& vertex_shader_src, const std::string& fragment_shader_src);
#endif // !ENABLE_SHADERS_MANAGER
void add_path(const GCodeProcessor::MoveVertex& move, unsigned int i_id, unsigned int s_id);
};
@ -112,9 +102,6 @@ class GCodeViewer
{
GLVolumeCollection volumes;
bool visible{ false };
#if !ENABLE_SHADERS_MANAGER
Shader shader;
#endif // !ENABLE_SHADERS_MANAGER
};
// helper to render extrusion paths
@ -225,9 +212,6 @@ public:
BoundingBoxf3 m_world_bounding_box;
std::array<float, 4> m_color{ 1.0f, 1.0f, 1.0f, 1.0f };
bool m_visible{ false };
#if !ENABLE_SHADERS_MANAGER
Shader m_shader;
#endif // !ENABLE_SHADERS_MANAGER
public:
void init();
@ -241,11 +225,6 @@ public:
void set_visible(bool visible) { m_visible = visible; }
void render() const;
#if !ENABLE_SHADERS_MANAGER
private:
void init_shader();
#endif // !ENABLE_SHADERS_MANAGER
};
struct Endpoints
@ -300,12 +279,8 @@ public:
bool init() {
set_toolpath_move_type_visible(GCodeProcessor::EMoveType::Extrude, true);
m_sequential_view.marker.init();
#if ENABLE_SHADERS_MANAGER
init_shaders();
return true;
#else
return init_shaders();
#endif // ENABLE_SHADERS_MANAGER
}
// extract rendering data from the given parameters
@ -349,11 +324,7 @@ public:
void enable_legend(bool enable) { m_legend_enabled = enable; }
private:
#if ENABLE_SHADERS_MANAGER
void init_shaders();
#else
bool init_shaders();
#endif // ENABLE_SHADERS_MANAGER
void load_toolpaths(const GCodeProcessor::Result& gcode_result);
void load_shells(const Print& print, bool initialized);
void refresh_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last) const;

View file

@ -156,16 +156,8 @@ GLCanvas3D::LayersEditing::~LayersEditing()
const float GLCanvas3D::LayersEditing::THICKNESS_BAR_WIDTH = 70.0f;
#if ENABLE_SHADERS_MANAGER
void GLCanvas3D::LayersEditing::init()
{
#else
bool GLCanvas3D::LayersEditing::init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename)
{
if (!m_shader.init(vertex_shader_filename, fragment_shader_filename))
return false;
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glGenTextures(1, (GLuint*)&m_z_texture_id));
glsafe(::glBindTexture(GL_TEXTURE_2D, m_z_texture_id));
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP));
@ -174,10 +166,6 @@ bool GLCanvas3D::LayersEditing::init(const std::string& vertex_shader_filename,
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST));
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1));
glsafe(::glBindTexture(GL_TEXTURE_2D, 0));
#if !ENABLE_SHADERS_MANAGER
return true;
#endif // !ENABLE_SHADERS_MANAGER
}
void GLCanvas3D::LayersEditing::set_config(const DynamicPrintConfig* config)
@ -210,11 +198,7 @@ void GLCanvas3D::LayersEditing::select_object(const Model &model, int object_id)
bool GLCanvas3D::LayersEditing::is_allowed() const
{
#if ENABLE_SHADERS_MANAGER
return wxGetApp().get_shader("variable_layer_height") != nullptr && m_z_texture_id > 0;
#else
return m_shader.is_initialized() && m_shader.get_shader()->shader_program_id > 0 && m_z_texture_id > 0;
#endif // ENABLE_SHADERS_MANAGER
}
bool GLCanvas3D::LayersEditing::is_enabled() const
@ -372,11 +356,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
bool GLCanvas3D::LayersEditing::is_initialized() const
{
#if ENABLE_SHADERS_MANAGER
return wxGetApp().get_shader("variable_layer_height") != nullptr;
#else
return m_shader.is_initialized();
#endif // ENABLE_SHADERS_MANAGER
}
std::string GLCanvas3D::LayersEditing::get_tooltip(const GLCanvas3D& canvas) const
@ -410,7 +390,6 @@ std::string GLCanvas3D::LayersEditing::get_tooltip(const GLCanvas3D& canvas) con
void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect) const
{
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height");
if (shader == nullptr)
return;
@ -422,15 +401,6 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
shader->set_uniform("z_cursor", m_object_max_z * this->get_cursor_z_relative(canvas));
shader->set_uniform("z_cursor_band_width", band_width);
shader->set_uniform("object_max_z", m_object_max_z);
#else
m_shader.start_using();
m_shader.set_uniform("z_to_texture_row", float(m_layers_texture.cells - 1) / (float(m_layers_texture.width) * m_object_max_z));
m_shader.set_uniform("z_texture_row_to_normalized", 1.0f / (float)m_layers_texture.height);
m_shader.set_uniform("z_cursor", m_object_max_z * this->get_cursor_z_relative(canvas));
m_shader.set_uniform("z_cursor_band_width", band_width);
m_shader.set_uniform("object_max_z", m_object_max_z);
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
glsafe(::glBindTexture(GL_TEXTURE_2D, m_z_texture_id));
@ -450,11 +420,7 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
glsafe(::glEnd());
glsafe(::glBindTexture(GL_TEXTURE_2D, 0));
#if ENABLE_SHADERS_MANAGER
shader->stop_using();
#else
m_shader.stop_using();
#endif // ENABLE_SHADERS_MANAGER
}
void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect) const
@ -488,7 +454,6 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
{
assert(this->is_allowed());
assert(this->last_object_id != -1);
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height");
if (shader == nullptr)
return;
@ -508,85 +473,31 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
shader->set_uniform("z_texture_row_to_normalized", 1.0f / float(m_layers_texture.height));
shader->set_uniform("z_cursor", float(m_object_max_z) * float(this->get_cursor_z_relative(canvas)));
shader->set_uniform("z_cursor_band_width", float(this->band_width));
#else
GLint shader_id = m_shader.get_shader()->shader_program_id;
assert(shader_id > 0);
GLint current_program_id;
glsafe(::glGetIntegerv(GL_CURRENT_PROGRAM, &current_program_id));
if (shader_id > 0 && shader_id != current_program_id)
// The layer editing shader is not yet active. Activate it.
glsafe(::glUseProgram(shader_id));
else
// The layer editing shader was already active.
current_program_id = -1;
// Initialize the layer height texture mapping.
GLsizei w = (GLsizei)m_layers_texture.width;
GLsizei h = (GLsizei)m_layers_texture.height;
GLsizei half_w = w / 2;
GLsizei half_h = h / 2;
glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
glsafe(::glBindTexture(GL_TEXTURE_2D, m_z_texture_id));
glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0));
glsafe(::glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, half_w, half_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0));
glsafe(::glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, m_layers_texture.data.data()));
glsafe(::glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, half_w, half_h, GL_RGBA, GL_UNSIGNED_BYTE, m_layers_texture.data.data() + m_layers_texture.width * m_layers_texture.height * 4));
for (const GLVolume* glvolume : volumes.volumes) {
// Render the object using the layer editing shader and texture.
if (! glvolume->is_active || glvolume->composite_id.object_id != this->last_object_id || glvolume->is_modifier)
continue;
GLint z_to_texture_row_id = ::glGetUniformLocation(shader_id, "z_to_texture_row");
GLint z_texture_row_to_normalized_id = ::glGetUniformLocation(shader_id, "z_texture_row_to_normalized");
GLint z_cursor_id = ::glGetUniformLocation(shader_id, "z_cursor");
GLint z_cursor_band_width_id = ::glGetUniformLocation(shader_id, "z_cursor_band_width");
GLint world_matrix_id = ::glGetUniformLocation(shader_id, "volume_world_matrix");
GLint object_max_z_id = ::glGetUniformLocation(shader_id, "object_max_z");
glcheck();
if (z_to_texture_row_id != -1 && z_texture_row_to_normalized_id != -1 && z_cursor_id != -1 && z_cursor_band_width_id != -1 && world_matrix_id != -1)
{
const_cast<LayersEditing*>(this)->generate_layer_height_texture();
// Uniforms were resolved, go ahead using the layer editing shader.
glsafe(::glUniform1f(z_to_texture_row_id, GLfloat(m_layers_texture.cells - 1) / (GLfloat(m_layers_texture.width) * GLfloat(m_object_max_z))));
glsafe(::glUniform1f(z_texture_row_to_normalized_id, GLfloat(1.0f / m_layers_texture.height)));
glsafe(::glUniform1f(z_cursor_id, GLfloat(m_object_max_z) * GLfloat(this->get_cursor_z_relative(canvas))));
glsafe(::glUniform1f(z_cursor_band_width_id, GLfloat(this->band_width)));
#endif // ENABLE_SHADERS_MANAGER
// Initialize the layer height texture mapping.
GLsizei w = (GLsizei)m_layers_texture.width;
GLsizei h = (GLsizei)m_layers_texture.height;
GLsizei half_w = w / 2;
GLsizei half_h = h / 2;
glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
glsafe(::glBindTexture(GL_TEXTURE_2D, m_z_texture_id));
glsafe(::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0));
glsafe(::glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, half_w, half_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0));
glsafe(::glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, m_layers_texture.data.data()));
glsafe(::glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, half_w, half_h, GL_RGBA, GL_UNSIGNED_BYTE, m_layers_texture.data.data() + m_layers_texture.width * m_layers_texture.height * 4));
for (const GLVolume* glvolume : volumes.volumes) {
// Render the object using the layer editing shader and texture.
if (! glvolume->is_active || glvolume->composite_id.object_id != this->last_object_id || glvolume->is_modifier)
continue;
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("volume_world_matrix", glvolume->world_matrix());
shader->set_uniform("object_max_z", GLfloat(0));
#else
if (world_matrix_id != -1)
glsafe(::glUniformMatrix4fv(world_matrix_id, 1, GL_FALSE, (const GLfloat*)glvolume->world_matrix().cast<float>().data()));
if (object_max_z_id != -1)
glsafe(::glUniform1f(object_max_z_id, GLfloat(0)));
#endif // ENABLE_SHADERS_MANAGER
glvolume->render();
}
// Revert back to the previous shader.
glBindTexture(GL_TEXTURE_2D, 0);
#if ENABLE_SHADERS_MANAGER
if (current_shader != nullptr)
current_shader->start_using();
#else
if (current_program_id > 0)
glsafe(::glUseProgram(current_program_id));
shader->set_uniform("volume_world_matrix", glvolume->world_matrix());
shader->set_uniform("object_max_z", GLfloat(0));
glvolume->render();
}
else
{
// Something went wrong. Just render the object.
assert(false);
for (const GLVolume* glvolume : volumes.volumes) {
// Render the object using the layer editing shader and texture.
if (!glvolume->is_active || glvolume->composite_id.object_id != this->last_object_id || glvolume->is_modifier)
continue;
glsafe(::glUniformMatrix4fv(world_matrix_id, 1, GL_FALSE, (const GLfloat*)glvolume->world_matrix().cast<float>().data()));
glvolume->render();
}
}
#endif // ENABLE_SHADERS_MANAGER
// Revert back to the previous shader.
glBindTexture(GL_TEXTURE_2D, 0);
if (current_shader != nullptr)
current_shader->start_using();
}
void GLCanvas3D::LayersEditing::adjust_layer_height_profile()
@ -1710,22 +1621,8 @@ bool GLCanvas3D::init()
if (m_multisample_allowed)
glsafe(::glEnable(GL_MULTISAMPLE));
#if ENABLE_SHADERS_MANAGER
if (m_main_toolbar.is_enabled())
m_layers_editing.init();
#else
if (!m_shader.init("gouraud.vs", "gouraud.fs"))
{
std::cout << "Unable to initialize gouraud shader: please, check that the files gouraud.vs and gouraud.fs are available" << std::endl;
return false;
}
if (m_main_toolbar.is_enabled() && !m_layers_editing.init("variable_layer_height.vs", "variable_layer_height.fs"))
{
std::cout << "Unable to initialize variable_layer_height shader: please, check that the files variable_layer_height.vs and variable_layer_height.fs are available" << std::endl;
return false;
}
#endif // ENABLE_SHADERS_MANAGER
#if ENABLE_GCODE_VIEWER
if (!m_main_toolbar.is_enabled())
@ -4585,13 +4482,8 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, bool
return ret;
};
#if ENABLE_SHADERS_MANAGER
static const std::array<float, 4> orange = { 0.923f, 0.504f, 0.264f, 1.0f };
static const std::array<float, 4> gray = { 0.64f, 0.64f, 0.64f, 1.0f };
#else
static const GLfloat orange[] = { 0.923f, 0.504f, 0.264f, 1.0f };
static const GLfloat gray[] = { 0.64f, 0.64f, 0.64f, 1.0f };
#endif // ENABLE_SHADERS_MANAGER
GLVolumePtrs visible_volumes;
@ -4635,7 +4527,6 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, bool
camera.apply_projection(box, near_z, far_z);
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* shader = wxGetApp().get_shader("gouraud");
if (shader == nullptr)
return;
@ -4648,43 +4539,14 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, bool
shader->start_using();
shader->set_uniform("print_box.volume_detection", 0);
#else
if (transparent_background)
glsafe(::glClearColor(0.0f, 0.0f, 0.0f, 0.0f));
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
glsafe(::glEnable(GL_DEPTH_TEST));
m_shader.start_using();
GLint shader_id = m_shader.get_shader_program_id();
GLint color_id = ::glGetUniformLocation(shader_id, "uniform_color");
GLint print_box_detection_id = ::glGetUniformLocation(shader_id, "print_box.volume_detection");
glcheck();
if (print_box_detection_id != -1)
glsafe(::glUniform1i(print_box_detection_id, 0));
#endif // ENABLE_SHADERS_MANAGER
for (const GLVolume* vol : visible_volumes)
{
#if ENABLE_SHADERS_MANAGER
shader->set_uniform("uniform_color", (vol->printable && !vol->is_outside) ? orange : gray);
#else
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (vol->printable && !vol->is_outside) ? orange : gray));
else
glsafe(::glColor4fv((vol->printable && !vol->is_outside) ? orange : gray));
#endif // ENABLE_SHADERS_MANAGER
vol->render();
}
#if ENABLE_SHADERS_MANAGER
shader->stop_using();
#else
m_shader.stop_using();
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glDisable(GL_DEPTH_TEST));
@ -5610,13 +5472,11 @@ void GLCanvas3D::_render_objects() const
m_camera_clipping_plane = m_gizmos.get_clipping_plane();
if (m_picking_enabled)
{
if (m_picking_enabled) {
// Update the layer editing selection to the first object selected, update the current object maximum Z.
const_cast<LayersEditing&>(m_layers_editing).select_object(*m_model, this->is_layers_editing_enabled() ? m_selection.get_object_idx() : -1);
if (m_config != nullptr)
{
if (m_config != nullptr) {
const BoundingBoxf3& bed_bb = wxGetApp().plater()->get_bed().get_bounding_box(false);
m_volumes.set_print_box((float)bed_bb.min(0), (float)bed_bb.min(1), 0.0f, (float)bed_bb.max(0), (float)bed_bb.max(1), (float)m_config->opt_float("max_print_height"));
m_volumes.check_outside_state(m_config, nullptr);
@ -5630,37 +5490,28 @@ void GLCanvas3D::_render_objects() const
m_volumes.set_clipping_plane(m_camera_clipping_plane.get_data());
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* shader = wxGetApp().get_shader("gouraud");
if (shader != nullptr)
{
if (shader != nullptr) {
shader->start_using();
#else
m_shader.start_using();
#endif // ENABLE_SHADERS_MANAGER
if (m_picking_enabled && !m_gizmos.is_dragging() && m_layers_editing.is_enabled() && (m_layers_editing.last_object_id != -1) && (m_layers_editing.object_max_z() > 0.0f)) {
int object_id = m_layers_editing.last_object_id;
m_volumes.render(GLVolumeCollection::Opaque, false, wxGetApp().plater()->get_camera().get_view_matrix(), [object_id](const GLVolume& volume) {
// Which volume to paint without the layer height profile shader?
return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id);
});
// Let LayersEditing handle rendering of the active object using the layer height profile shader.
m_layers_editing.render_volumes(*this, this->m_volumes);
}
else {
if (m_picking_enabled && !m_gizmos.is_dragging() && m_layers_editing.is_enabled() && (m_layers_editing.last_object_id != -1) && (m_layers_editing.object_max_z() > 0.0f)) {
int object_id = m_layers_editing.last_object_id;
m_volumes.render(GLVolumeCollection::Opaque, false, wxGetApp().plater()->get_camera().get_view_matrix(), [object_id](const GLVolume& volume) {
// Which volume to paint without the layer height profile shader?
return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id);
});
// Let LayersEditing handle rendering of the active object using the layer height profile shader.
m_layers_editing.render_volumes(*this, this->m_volumes);
} else {
// do not cull backfaces to show broken geometry, if any
m_volumes.render(GLVolumeCollection::Opaque, m_picking_enabled, wxGetApp().plater()->get_camera().get_view_matrix(), [this](const GLVolume& volume) {
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
});
}
}
m_volumes.render(GLVolumeCollection::Transparent, false, wxGetApp().plater()->get_camera().get_view_matrix());
#if ENABLE_SHADERS_MANAGER
shader->stop_using();
m_volumes.render(GLVolumeCollection::Transparent, false, wxGetApp().plater()->get_camera().get_view_matrix());
shader->stop_using();
}
#else
m_shader.stop_using();
#endif // ENABLE_SHADERS_MANAGER
m_camera_clipping_plane = ClippingPlane::ClipsNothing();
}
@ -6078,15 +5929,7 @@ void GLCanvas3D::_render_sla_slices() const
void GLCanvas3D::_render_selection_sidebar_hints() const
{
#if ENABLE_GCODE_VIEWER
m_selection.render_sidebar_hints(m_sidebar_field);
#else
#if ENABLE_SHADERS_MANAGER
m_selection.render_sidebar_hints(m_sidebar_field);
#else
m_selection.render_sidebar_hints(m_sidebar_field, m_shader);
#endif // ENABLE_SHADERS_MANAGER
#endif // ENABLE_GCODE_VIEWER
}
void GLCanvas3D::_update_volumes_hover_state() const

View file

@ -7,9 +7,6 @@
#include "3DScene.hpp"
#include "GLToolbar.hpp"
#if !ENABLE_SHADERS_MANAGER
#include "GLShader.hpp"
#endif // !ENABLE_SHADERS_MANAGER
#include "Event.hpp"
#include "Selection.hpp"
#include "Gizmos/GLGizmosManager.hpp"
@ -169,9 +166,6 @@ private:
private:
bool m_enabled;
#if !ENABLE_SHADERS_MANAGER
Shader m_shader;
#endif // !ENABLE_SHADERS_MANAGER
unsigned int m_z_texture_id;
// Not owned by LayersEditing.
const DynamicPrintConfig *m_config;
@ -218,11 +212,8 @@ private:
LayersEditing();
~LayersEditing();
#if ENABLE_SHADERS_MANAGER
void init();
#else
bool init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename);
#endif // ENABLE_SHADERS_MANAGER
void set_config(const DynamicPrintConfig* config);
void select_object(const Model &model, int object_id);
@ -465,9 +456,6 @@ private:
WarningTexture m_warning_texture;
wxTimer m_timer;
LayersEditing m_layers_editing;
#if !ENABLE_SHADERS_MANAGER
Shader m_shader;
#endif // !ENABLE_SHADERS_MANAGER
Mouse m_mouse;
mutable GLGizmosManager m_gizmos;
mutable GLToolbar m_main_toolbar;
@ -597,9 +585,6 @@ public:
void set_color_by(const std::string& value);
void refresh_camera_scene_box();
#if !ENABLE_SHADERS_MANAGER
const Shader& get_shader() const { return m_shader; }
#endif // !ENABLE_SHADERS_MANAGER
BoundingBoxf3 volumes_bounding_box() const;
BoundingBoxf3 scene_bounding_box() const;

View file

@ -8,7 +8,6 @@
#include <GL/glew.h>
#include <cassert>
#if ENABLE_SHADERS_MANAGER
#include <boost/log/trivial.hpp>
namespace Slic3r {
@ -302,364 +301,3 @@ int GLShaderProgram::get_uniform_location(const char* name) const
}
} // namespace Slic3r
#else
#include <string>
#include <utility>
#include <assert.h>
namespace Slic3r {
GLShader::~GLShader()
{
assert(fragment_program_id == 0);
assert(vertex_program_id == 0);
assert(shader_program_id == 0);
}
// A safe wrapper around glGetString to report a "N/A" string in case glGetString returns nullptr.
inline std::string gl_get_string_safe(GLenum param)
{
const char *value = (const char*)glGetString(param);
return std::string(value ? value : "N/A");
}
bool GLShader::load_from_text(const char *fragment_shader, const char *vertex_shader)
{
std::string gl_version = gl_get_string_safe(GL_VERSION);
int major = atoi(gl_version.c_str());
//int minor = atoi(gl_version.c_str() + gl_version.find('.') + 1);
if (major < 2) {
// Cannot create a shader object on OpenGL 1.x.
// Form an error message.
std::string gl_vendor = gl_get_string_safe(GL_VENDOR);
std::string gl_renderer = gl_get_string_safe(GL_RENDERER);
std::string glsl_version = gl_get_string_safe(GL_SHADING_LANGUAGE_VERSION);
last_error = "Your computer does not support OpenGL shaders.\n";
#ifdef _WIN32
if (gl_vendor == "Microsoft Corporation" && gl_renderer == "GDI Generic") {
last_error = "Windows is using a software OpenGL renderer.\n"
"You are either connected over remote desktop,\n"
"or a hardware acceleration is not available.\n";
}
#endif
last_error += "GL version: " + gl_version + "\n";
last_error += "vendor: " + gl_vendor + "\n";
last_error += "renderer: " + gl_renderer + "\n";
last_error += "GLSL version: " + glsl_version + "\n";
return false;
}
if (fragment_shader != nullptr) {
this->fragment_program_id = ::glCreateShader(GL_FRAGMENT_SHADER);
glcheck();
if (this->fragment_program_id == 0) {
last_error = "glCreateShader(GL_FRAGMENT_SHADER) failed.";
return false;
}
GLint len = (GLint)strlen(fragment_shader);
glsafe(::glShaderSource(this->fragment_program_id, 1, &fragment_shader, &len));
glsafe(::glCompileShader(this->fragment_program_id));
GLint params;
glsafe(::glGetShaderiv(this->fragment_program_id, GL_COMPILE_STATUS, &params));
if (params == GL_FALSE) {
// Compilation failed. Get the log.
glsafe(::glGetShaderiv(this->fragment_program_id, GL_INFO_LOG_LENGTH, &params));
std::vector<char> msg(params);
glsafe(::glGetShaderInfoLog(this->fragment_program_id, params, &params, msg.data()));
this->last_error = std::string("Fragment shader compilation failed:\n") + msg.data();
this->release();
return false;
}
}
if (vertex_shader != nullptr) {
this->vertex_program_id = ::glCreateShader(GL_VERTEX_SHADER);
glcheck();
if (this->vertex_program_id == 0) {
last_error = "glCreateShader(GL_VERTEX_SHADER) failed.";
this->release();
return false;
}
GLint len = (GLint)strlen(vertex_shader);
glsafe(::glShaderSource(this->vertex_program_id, 1, &vertex_shader, &len));
glsafe(::glCompileShader(this->vertex_program_id));
GLint params;
glsafe(::glGetShaderiv(this->vertex_program_id, GL_COMPILE_STATUS, &params));
if (params == GL_FALSE) {
// Compilation failed. Get the log.
glsafe(::glGetShaderiv(this->vertex_program_id, GL_INFO_LOG_LENGTH, &params));
std::vector<char> msg(params);
glsafe(::glGetShaderInfoLog(this->vertex_program_id, params, &params, msg.data()));
this->last_error = std::string("Vertex shader compilation failed:\n") + msg.data();
this->release();
return false;
}
}
// Link shaders
this->shader_program_id = ::glCreateProgram();
glcheck();
if (this->shader_program_id == 0) {
last_error = "glCreateProgram() failed.";
this->release();
return false;
}
if (this->fragment_program_id)
glsafe(::glAttachShader(this->shader_program_id, this->fragment_program_id));
if (this->vertex_program_id)
glsafe(::glAttachShader(this->shader_program_id, this->vertex_program_id));
glsafe(::glLinkProgram(this->shader_program_id));
GLint params;
glsafe(::glGetProgramiv(this->shader_program_id, GL_LINK_STATUS, &params));
if (params == GL_FALSE) {
// Linking failed. Get the log.
glsafe(::glGetProgramiv(this->shader_program_id, GL_INFO_LOG_LENGTH, &params));
std::vector<char> msg(params);
glsafe(::glGetProgramInfoLog(this->shader_program_id, params, &params, msg.data()));
this->last_error = std::string("Shader linking failed:\n") + msg.data();
this->release();
return false;
}
last_error.clear();
return true;
}
bool GLShader::load_from_file(const char* fragment_shader_filename, const char* vertex_shader_filename)
{
const std::string& path = resources_dir() + "/shaders/";
boost::nowide::ifstream vs(path + std::string(vertex_shader_filename), boost::nowide::ifstream::binary);
if (!vs.good())
return false;
vs.seekg(0, vs.end);
int file_length = (int)vs.tellg();
vs.seekg(0, vs.beg);
std::string vertex_shader(file_length, '\0');
vs.read(vertex_shader.data(), file_length);
if (!vs.good())
return false;
vs.close();
boost::nowide::ifstream fs(path + std::string(fragment_shader_filename), boost::nowide::ifstream::binary);
if (!fs.good())
return false;
fs.seekg(0, fs.end);
file_length = (int)fs.tellg();
fs.seekg(0, fs.beg);
std::string fragment_shader(file_length, '\0');
fs.read(fragment_shader.data(), file_length);
if (!fs.good())
return false;
fs.close();
return load_from_text(fragment_shader.c_str(), vertex_shader.c_str());
}
void GLShader::release()
{
if (this->shader_program_id) {
if (this->vertex_program_id)
glsafe(::glDetachShader(this->shader_program_id, this->vertex_program_id));
if (this->fragment_program_id)
glsafe(::glDetachShader(this->shader_program_id, this->fragment_program_id));
glsafe(::glDeleteProgram(this->shader_program_id));
this->shader_program_id = 0;
}
if (this->vertex_program_id) {
glsafe(::glDeleteShader(this->vertex_program_id));
this->vertex_program_id = 0;
}
if (this->fragment_program_id) {
glsafe(::glDeleteShader(this->fragment_program_id));
this->fragment_program_id = 0;
}
}
void GLShader::enable() const
{
glsafe(::glUseProgram(this->shader_program_id));
}
void GLShader::disable() const
{
glsafe(::glUseProgram(0));
}
// Return shader vertex attribute ID
int GLShader::get_attrib_location(const char *name) const
{
return this->shader_program_id ? glGetAttribLocation(this->shader_program_id, name) : -1;
}
// Return shader uniform variable ID
int GLShader::get_uniform_location(const char *name) const
{
return this->shader_program_id ? glGetUniformLocation(this->shader_program_id, name) : -1;
}
bool GLShader::set_uniform(const char *name, float value) const
{
int id = this->get_uniform_location(name);
if (id >= 0) {
glsafe(::glUniform1fARB(id, value));
return true;
}
return false;
}
bool GLShader::set_uniform(const char* name, const float* matrix) const
{
int id = get_uniform_location(name);
if (id >= 0)
{
glsafe(::glUniformMatrix4fv(id, 1, GL_FALSE, (const GLfloat*)matrix));
return true;
}
return false;
}
bool GLShader::set_uniform(const char* name, int value) const
{
int id = get_uniform_location(name);
if (id >= 0)
{
glsafe(::glUniform1i(id, value));
return true;
}
return false;
}
/*
# Set shader vector
sub SetVector
{
my($self,$var,@values) = @_;
my $id = $self->Map($var);
return 'Unable to map $var' if (!defined($id));
my $count = scalar(@values);
eval('glUniform'.$count.'fARB($id,@values)');
return '';
}
# Set shader 4x4 matrix
sub SetMatrix
{
my($self,$var,$oga) = @_;
my $id = $self->Map($var);
return 'Unable to map $var' if (!defined($id));
glUniformMatrix4fvARB_c($id,1,0,$oga->ptr());
return '';
}
*/
Shader::Shader()
: m_shader(nullptr)
{
}
Shader::~Shader()
{
reset();
}
bool Shader::init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename)
{
if (is_initialized())
return true;
m_shader = new GLShader();
if (m_shader != nullptr)
{
if (!m_shader->load_from_file(fragment_shader_filename.c_str(), vertex_shader_filename.c_str()))
{
std::cout << "Compilaton of shader failed:" << std::endl;
std::cout << m_shader->last_error << std::endl;
reset();
return false;
}
}
return true;
}
bool Shader::is_initialized() const
{
return (m_shader != nullptr);
}
bool Shader::start_using() const
{
if (is_initialized())
{
m_shader->enable();
return true;
}
else
return false;
}
void Shader::stop_using() const
{
if (m_shader != nullptr)
m_shader->disable();
}
int Shader::get_attrib_location(const std::string& name) const
{
return (m_shader != nullptr) ? m_shader->get_attrib_location(name.c_str()) : -1;
}
int Shader::get_uniform_location(const std::string& name) const
{
return (m_shader != nullptr) ? m_shader->get_uniform_location(name.c_str()) : -1;
}
void Shader::set_uniform(const std::string& name, float value) const
{
if (m_shader != nullptr)
m_shader->set_uniform(name.c_str(), value);
}
void Shader::set_uniform(const std::string& name, const float* matrix) const
{
if (m_shader != nullptr)
m_shader->set_uniform(name.c_str(), matrix);
}
void Shader::set_uniform(const std::string& name, bool value) const
{
if (m_shader != nullptr)
m_shader->set_uniform(name.c_str(), value ? 1 : 0);
}
unsigned int Shader::get_shader_program_id() const
{
return (m_shader != nullptr) ? m_shader->shader_program_id : 0;
}
void Shader::reset()
{
if (m_shader != nullptr)
{
m_shader->release();
delete m_shader;
m_shader = nullptr;
}
}
} // namespace Slic3r
#endif // ENABLE_SHADERS_MANAGER

View file

@ -1,7 +1,6 @@
#ifndef slic3r_GLShader_hpp_
#define slic3r_GLShader_hpp_
#if ENABLE_SHADERS_MANAGER
#include <array>
#include <string>
@ -59,75 +58,5 @@ public:
};
} // namespace Slic3r
#else
#include "libslic3r/libslic3r.h"
#include "libslic3r/Point.hpp"
namespace Slic3r {
class GLShader
{
public:
GLShader() :
fragment_program_id(0),
vertex_program_id(0),
shader_program_id(0)
{}
~GLShader();
bool load_from_text(const char *fragment_shader, const char *vertex_shader);
bool load_from_file(const char* fragment_shader_filename, const char* vertex_shader_filename);
void release();
int get_attrib_location(const char *name) const;
int get_uniform_location(const char *name) const;
bool set_uniform(const char *name, float value) const;
bool set_uniform(const char* name, const float* matrix) const;
bool set_uniform(const char* name, int value) const;
void enable() const;
void disable() const;
unsigned int fragment_program_id;
unsigned int vertex_program_id;
unsigned int shader_program_id;
std::string last_error;
};
class Shader
{
GLShader* m_shader;
public:
Shader();
~Shader();
bool init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename);
bool is_initialized() const;
bool start_using() const;
void stop_using() const;
int get_attrib_location(const std::string& name) const;
int get_uniform_location(const std::string& name) const;
void set_uniform(const std::string& name, float value) const;
void set_uniform(const std::string& name, const float* matrix) const;
void set_uniform(const std::string& name, bool value) const;
const GLShader* get_shader() const { return m_shader; }
unsigned int get_shader_program_id() const;
private:
void reset();
};
}
#endif // ENABLE_SHADERS_MANAGER
#endif /* slic3r_GLShader_hpp_ */

View file

@ -7,8 +7,6 @@
#include <GL/glew.h>
#if ENABLE_SHADERS_MANAGER
namespace Slic3r {
std::pair<bool, std::string> GLShadersManager::init()
@ -77,4 +75,3 @@ GLShaderProgram* GLShadersManager::get_current_shader()
} // namespace Slic3r
#endif // ENABLE_SHADERS_MANAGER

View file

@ -1,8 +1,6 @@
#ifndef slic3r_GLShadersManager_hpp_
#define slic3r_GLShadersManager_hpp_
#if ENABLE_SHADERS_MANAGER
#include "GLShader.hpp"
#include <vector>
@ -29,6 +27,4 @@ public:
} // namespace Slic3r
#endif // ENABLE_SHADERS_MANAGER
#endif // slic3r_GLShadersManager_hpp_

View file

@ -217,10 +217,8 @@ public:
void gcode_thumbnails_debug();
#endif // ENABLE_THUMBNAIL_GENERATOR_DEBUG
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* get_shader(const std::string& shader_name) { return m_opengl_mgr.get_shader(shader_name); }
GLShaderProgram* get_current_shader() { return m_opengl_mgr.get_current_shader(); }
#endif // ENABLE_SHADERS_MANAGER
bool is_gl_version_greater_or_equal_to(unsigned int major, unsigned int minor) const { return m_opengl_mgr.get_gl_info().is_version_greater_or_equal_to(major, minor); }
bool is_glsl_version_greater_or_equal_to(unsigned int major, unsigned int minor) const { return m_opengl_mgr.get_gl_info().is_glsl_version_greater_or_equal_to(major, minor); }

View file

@ -28,14 +28,12 @@
namespace Slic3r {
namespace GUI {
#if ENABLE_SHADERS_MANAGER
// A safe wrapper around glGetString to report a "N/A" string in case glGetString returns nullptr.
inline std::string gl_get_string_safe(GLenum param, const std::string& default_value)
{
const char* value = (const char*)::glGetString(param);
return std::string((value != nullptr) ? value : default_value);
}
#endif // ENABLE_SHADERS_MANAGER
const std::string& OpenGLManager::GLInfo::get_version() const
{
@ -94,28 +92,10 @@ float OpenGLManager::GLInfo::get_max_anisotropy() const
void OpenGLManager::GLInfo::detect() const
{
#if ENABLE_SHADERS_MANAGER
m_version = gl_get_string_safe(GL_VERSION, "N/A");
m_glsl_version = gl_get_string_safe(GL_SHADING_LANGUAGE_VERSION, "N/A");
m_vendor = gl_get_string_safe(GL_VENDOR, "N/A");
m_renderer = gl_get_string_safe(GL_RENDERER, "N/A");
#else
const char* data = (const char*)::glGetString(GL_VERSION);
if (data != nullptr)
m_version = data;
data = (const char*)::glGetString(GL_SHADING_LANGUAGE_VERSION);
if (data != nullptr)
m_glsl_version = data;
data = (const char*)::glGetString(GL_VENDOR);
if (data != nullptr)
m_vendor = data;
data = (const char*)::glGetString(GL_RENDERER);
if (data != nullptr)
m_renderer = data;
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_max_tex_size));
@ -132,10 +112,8 @@ void OpenGLManager::GLInfo::detect() const
static bool version_greater_or_equal_to(const std::string& version, unsigned int major, unsigned int minor)
{
#if ENABLE_SHADERS_MANAGER
if (version == "N/A")
return false;
#endif // ENABLE_SHADERS_MANAGER
std::vector<std::string> tokens;
boost::split(tokens, version, boost::is_any_of(" "), boost::token_compress_on);
@ -193,26 +171,15 @@ std::string OpenGLManager::GLInfo::to_string(bool format_as_html, bool extension
std::string line_end = format_as_html ? "<br>" : "\n";
out << h2_start << "OpenGL installation" << h2_end << line_end;
#if ENABLE_SHADERS_MANAGER
out << b_start << "GL version: " << b_end << m_version << line_end;
out << b_start << "Vendor: " << b_end << m_vendor << line_end;
out << b_start << "Renderer: " << b_end << m_renderer << line_end;
out << b_start << "GLSL version: " << b_end << m_glsl_version << line_end;
#else
out << b_start << "GL version: " << b_end << (m_version.empty() ? "N/A" : m_version) << line_end;
out << b_start << "Vendor: " << b_end << (m_vendor.empty() ? "N/A" : m_vendor) << line_end;
out << b_start << "Renderer: " << b_end << (m_renderer.empty() ? "N/A" : m_renderer) << line_end;
out << b_start << "GLSL version: " << b_end << (m_glsl_version.empty() ? "N/A" : m_glsl_version) << line_end;
#endif // ENABLE_SHADERS_MANAGER
if (extensions)
{
std::vector<std::string> extensions_list;
#if ENABLE_SHADERS_MANAGER
std::string extensions_str = gl_get_string_safe(GL_EXTENSIONS, "");
#else
std::string extensions_str = (const char*)::glGetString(GL_EXTENSIONS);
#endif // ENABLE_SHADERS_MANAGER
boost::split(extensions_list, extensions_str, boost::is_any_of(" "), boost::token_compress_off);
if (!extensions_list.empty())
@ -244,9 +211,7 @@ OpenGLManager::OSInfo OpenGLManager::s_os_info;
OpenGLManager::~OpenGLManager()
{
#if ENABLE_SHADERS_MANAGER
m_shaders_manager.shutdown();
#endif // ENABLE_SHADERS_MANAGER
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
#ifdef __APPLE__
@ -289,13 +254,8 @@ bool OpenGLManager::init_gl()
else
s_framebuffers_type = EFramebufferType::Unknown;
#if ENABLE_SHADERS_MANAGER
bool valid_version = s_gl_info.is_version_greater_or_equal_to(2, 0);
if (!valid_version) {
#else
if (!s_gl_info.is_version_greater_or_equal_to(2, 0)) {
#endif // ENABLE_SHADERS_MANAGER
// Complain about the OpenGL version.
wxString message = from_u8((boost::format(
_utf8(L("PrusaSlicer requires OpenGL 2.0 capable graphics driver to run correctly, \n"
@ -309,7 +269,6 @@ bool OpenGLManager::init_gl()
wxMessageBox(message, wxString("PrusaSlicer - ") + _L("Unsupported OpenGL version"), wxOK | wxICON_ERROR);
}
#if ENABLE_SHADERS_MANAGER
if (valid_version) {
// load shaders
auto [result, error] = m_shaders_manager.init();
@ -319,7 +278,6 @@ bool OpenGLManager::init_gl()
wxMessageBox(message, wxString("PrusaSlicer - ") + _L("Error loading shaders"), wxOK | wxICON_ERROR);
}
}
#endif // ENABLE_SHADERS_MANAGER
}
return true;
@ -327,8 +285,7 @@ bool OpenGLManager::init_gl()
wxGLContext* OpenGLManager::init_glcontext(wxGLCanvas& canvas)
{
if (m_context == nullptr)
{
if (m_context == nullptr) {
m_context = new wxGLContext(&canvas);
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5

View file

@ -1,9 +1,7 @@
#ifndef slic3r_OpenGLManager_hpp_
#define slic3r_OpenGLManager_hpp_
#if ENABLE_SHADERS_MANAGER
#include "GLShadersManager.hpp"
#endif // ENABLE_SHADERS_MANAGER
class wxWindow;
class wxGLCanvas;
@ -75,9 +73,7 @@ private:
bool m_gl_initialized{ false };
wxGLContext* m_context{ nullptr };
#if ENABLE_SHADERS_MANAGER
GLShadersManager m_shaders_manager;
#endif // ENABLE_SHADERS_MANAGER
static GLInfo s_gl_info;
#if ENABLE_HACK_CLOSING_ON_OSX_10_9_5
#ifdef __APPLE__
@ -96,10 +92,8 @@ public:
bool init_gl();
wxGLContext* init_glcontext(wxGLCanvas& canvas);
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* get_shader(const std::string& shader_name) { return m_shaders_manager.get_shader(shader_name); }
GLShaderProgram* get_current_shader() { return m_shaders_manager.get_current_shader(); }
#endif // ENABLE_SHADERS_MANAGER
static bool are_compressed_textures_supported() { return s_compressed_textures_supported; }
static bool can_multisample() { return s_multisample == EMultisampleState::Enabled; }

View file

@ -112,14 +112,6 @@ bool Selection::init()
#if ENABLE_GCODE_VIEWER
m_arrow.init_from(straight_arrow(10.0f, 5.0f, 5.0f, 10.0f, 1.0f));
m_curved_arrow.init_from(circular_arrow(16, 10.0f, 5.0f, 10.0f, 5.0f, 1.0f));
#if !ENABLE_SHADERS_MANAGER
if (!m_arrows_shader.init("gouraud_light.vs", "gouraud_light.fs"))
{
BOOST_LOG_TRIVIAL(error) << "Unable to initialize gouraud_light shader: please, check that the files gouraud_light.vs and gouraud_light.fs are available";
return false;
}
#endif // !ENABLE_SHADERS_MANAGER
#else
if (!m_arrow.init())
return false;
@ -1246,76 +1238,40 @@ void Selection::render_center(bool gizmo_is_dragging) const
}
#endif // ENABLE_RENDER_SELECTION_CENTER
#if ENABLE_GCODE_VIEWER
void Selection::render_sidebar_hints(const std::string& sidebar_field) const
#else
#if ENABLE_SHADERS_MANAGER
void Selection::render_sidebar_hints(const std::string& sidebar_field) const
#else
void Selection::render_sidebar_hints(const std::string& sidebar_field, const Shader& shader) const
#endif // ENABLE_SHADERS_MANAGER
#endif // ENABLE_GCODE_VIEWER
{
if (sidebar_field.empty())
return;
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* shader = nullptr;
#endif // ENABLE_SHADERS_MANAGER
if (!boost::starts_with(sidebar_field, "layer"))
{
#if ENABLE_GCODE_VIEWER
#if ENABLE_SHADERS_MANAGER
shader = wxGetApp().get_shader("gouraud_light");
if (shader == nullptr)
return;
shader->start_using();
#else
if (!m_arrows_shader.is_initialized())
return;
m_arrows_shader.start_using();
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
#else
#if ENABLE_SHADERS_MANAGER
shader = wxGetApp().get_shader("gouraud_light");
if (shader == nullptr)
return;
shader->start_using();
#else
shader.start_using();
glsafe(::glEnable(GL_LIGHTING));
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
#endif // ENABLE_GCODE_VIEWER
}
glsafe(::glEnable(GL_DEPTH_TEST));
glsafe(::glPushMatrix());
if (!boost::starts_with(sidebar_field, "layer"))
{
if (!boost::starts_with(sidebar_field, "layer")) {
const Vec3d& center = get_bounding_box().center();
if (is_single_full_instance() && !wxGetApp().obj_manipul()->get_world_coordinates())
{
if (is_single_full_instance() && !wxGetApp().obj_manipul()->get_world_coordinates()) {
glsafe(::glTranslated(center(0), center(1), center(2)));
if (!boost::starts_with(sidebar_field, "position"))
{
if (!boost::starts_with(sidebar_field, "position")) {
Transform3d orient_matrix = Transform3d::Identity();
if (boost::starts_with(sidebar_field, "scale"))
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
else if (boost::starts_with(sidebar_field, "rotation"))
{
else if (boost::starts_with(sidebar_field, "rotation")) {
if (boost::ends_with(sidebar_field, "x"))
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
else if (boost::ends_with(sidebar_field, "y"))
{
else if (boost::ends_with(sidebar_field, "y")) {
const Vec3d& rotation = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_rotation();
if (rotation(0) == 0.0)
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
@ -1326,21 +1282,16 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field, const Sha
glsafe(::glMultMatrixd(orient_matrix.data()));
}
}
else if (is_single_volume() || is_single_modifier())
{
} else if (is_single_volume() || is_single_modifier()) {
glsafe(::glTranslated(center(0), center(1), center(2)));
Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
if (!boost::starts_with(sidebar_field, "position"))
orient_matrix = orient_matrix * (*m_volumes)[*m_list.begin()]->get_volume_transformation().get_matrix(true, false, true, true);
glsafe(::glMultMatrixd(orient_matrix.data()));
}
else
{
} else {
glsafe(::glTranslated(center(0), center(1), center(2)));
if (requires_local_axes())
{
if (requires_local_axes()) {
Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
glsafe(::glMultMatrixd(orient_matrix.data()));
}
@ -1359,22 +1310,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field, const Sha
glsafe(::glPopMatrix());
if (!boost::starts_with(sidebar_field, "layer"))
{
#if ENABLE_GCODE_VIEWER
#if ENABLE_SHADERS_MANAGER
shader->stop_using();
#else
m_arrows_shader.stop_using();
#endif // ENABLE_SHADERS_MANAGER
#else
#if ENABLE_SHADERS_MANAGER
shader->stop_using();
#else
glsafe(::glDisable(GL_LIGHTING));
shader.stop_using();
#endif // ENABLE_SHADERS_MANAGER
#endif // ENABLE_GCODE_VIEWER
}
}
bool Selection::requires_local_axes() const
@ -1977,50 +1913,21 @@ void Selection::render_bounding_box(const BoundingBoxf3& box, float* color) cons
#if ENABLE_GCODE_VIEWER
void Selection::render_sidebar_position_hints(const std::string& sidebar_field) const
{
#if ENABLE_SHADERS_MANAGER
auto set_color = [](Axis axis) {
GLShaderProgram* shader = wxGetApp().get_current_shader();
if (shader != nullptr)
shader->set_uniform("uniform_color", AXES_COLOR[axis], 4);
};
#endif // ENABLE_SHADERS_MANAGER
#if !ENABLE_SHADERS_MANAGER
GLint color_id = ::glGetUniformLocation(m_arrows_shader.get_shader_program_id(), "uniform_color");
#endif // !ENABLE_SHADERS_MANAGER
if (boost::ends_with(sidebar_field, "x"))
{
#if ENABLE_SHADERS_MANAGER
if (boost::ends_with(sidebar_field, "x")) {
set_color(X);
#else
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)AXES_COLOR[0]));
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glRotated(-90.0, 0.0, 0.0, 1.0));
m_arrow.render();
}
else if (boost::ends_with(sidebar_field, "y"))
{
#if ENABLE_SHADERS_MANAGER
} else if (boost::ends_with(sidebar_field, "y")) {
set_color(Y);
#else
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)AXES_COLOR[1]));
#endif // ENABLE_SHADERS_MANAGER
m_arrow.render();
}
else if (boost::ends_with(sidebar_field, "z"))
{
#if ENABLE_SHADERS_MANAGER
} else if (boost::ends_with(sidebar_field, "z")) {
set_color(Z);
#else
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)AXES_COLOR[2]));
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glRotated(90.0, 1.0, 0.0, 0.0));
m_arrow.render();
}
@ -2046,51 +1953,22 @@ void Selection::render_sidebar_position_hints(const std::string& sidebar_field)
#if ENABLE_GCODE_VIEWER
void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field) const
{
#if ENABLE_SHADERS_MANAGER
auto set_color = [](Axis axis) {
GLShaderProgram* shader = wxGetApp().get_current_shader();
if (shader != nullptr)
shader->set_uniform("uniform_color", AXES_COLOR[axis], 4);
};
#endif // ENABLE_SHADERS_MANAGER
#if !ENABLE_SHADERS_MANAGER
GLint color_id = ::glGetUniformLocation(m_arrows_shader.get_shader_program_id(), "uniform_color");
#endif // !ENABLE_SHADERS_MANAGER
if (boost::ends_with(sidebar_field, "x"))
{
#if ENABLE_SHADERS_MANAGER
if (boost::ends_with(sidebar_field, "x")) {
set_color(X);
#else
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)AXES_COLOR[0]));
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glRotated(90.0, 0.0, 1.0, 0.0));
render_sidebar_rotation_hint(X);
}
else if (boost::ends_with(sidebar_field, "y"))
{
#if ENABLE_SHADERS_MANAGER
} else if (boost::ends_with(sidebar_field, "y")) {
set_color(Y);
#else
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)AXES_COLOR[1]));
#endif // ENABLE_SHADERS_MANAGER
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
render_sidebar_rotation_hint(Y);
}
else if (boost::ends_with(sidebar_field, "z"))
{
#if ENABLE_SHADERS_MANAGER
} else if (boost::ends_with(sidebar_field, "z")) {
set_color(Z);
#else
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (const GLfloat*)AXES_COLOR[2]));
#endif // ENABLE_SHADERS_MANAGER
render_sidebar_rotation_hint(Z);
}
}
@ -2230,23 +2108,12 @@ void Selection::render_sidebar_rotation_hint(Axis axis) const
m_curved_arrow.render();
}
#if ENABLE_SHADERS_MANAGER
void Selection::render_sidebar_scale_hint(Axis axis) const
#else
void Selection::render_sidebar_scale_hint(Axis axis) const
#endif // ENABLE_SHADERS_MANAGER
{
#if ENABLE_GCODE_VIEWER
#if ENABLE_SHADERS_MANAGER
GLShaderProgram* shader = wxGetApp().get_current_shader();
if (shader != nullptr)
shader->set_uniform("uniform_color", (requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling()) ? UNIFORM_SCALE_COLOR : AXES_COLOR[axis], 4);
#else
GLint color_id = ::glGetUniformLocation(m_arrows_shader.get_shader_program_id(), "uniform_color");
if (color_id >= 0)
glsafe(::glUniform4fv(color_id, 1, (requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling()) ? (const GLfloat*)UNIFORM_SCALE_COLOR : (const GLfloat*)AXES_COLOR[axis]));
#endif // ENABLE_SHADERS_MANAGER
#else
m_arrow.set_color(((requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling()) ? UNIFORM_SCALE_COLOR : AXES_COLOR[axis]), 3);
#endif // ENABLE_GCODE_VIEWER

View file

@ -6,13 +6,6 @@
#include "3DScene.hpp"
#if ENABLE_GCODE_VIEWER
#include "GLModel.hpp"
#if !ENABLE_SHADERS_MANAGER
#include "GLShader.hpp"
#endif // !ENABLE_SHADERS_MANAGER
#else
#if !ENABLE_SHADERS_MANAGER
#include "GLShader.hpp"
#endif // !ENABLE_SHADERS_MANAGER
#endif // ENABLE_GCODE_VIEWER
#if ENABLE_RENDER_SELECTION_CENTER
@ -24,9 +17,7 @@ namespace Slic3r {
#if !ENABLE_GCODE_VIEWER
class Shader;
#endif // !ENABLE_GCODE_VIEWER
#if ENABLE_SHADERS_MANAGER
class GLShaderProgram;
#endif // ENABLE_SHADERS_MANAGER
namespace GUI {
class TransformationType
{
@ -218,9 +209,6 @@ private:
#if ENABLE_GCODE_VIEWER
GL_Model m_arrow;
GL_Model m_curved_arrow;
#if !ENABLE_SHADERS_MANAGER
Shader m_arrows_shader;
#endif // !ENABLE_SHADERS_MANAGER
#else
mutable GLArrow m_arrow;
mutable GLCurvedArrow m_curved_arrow;
@ -339,15 +327,7 @@ public:
#if ENABLE_RENDER_SELECTION_CENTER
void render_center(bool gizmo_is_dragging) const;
#endif // ENABLE_RENDER_SELECTION_CENTER
#if ENABLE_GCODE_VIEWER
void render_sidebar_hints(const std::string& sidebar_field) const;
#else
#if ENABLE_SHADERS_MANAGER
void render_sidebar_hints(const std::string& sidebar_field) const;
#else
void render_sidebar_hints(const std::string& sidebar_field, const Shader& shader) const;
#endif // ENABLE_SHADERS_MANAGER
#endif // ENABLE_GCODE_VIEWER
bool requires_local_axes() const;