Tech ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES renamed as ENABLE_GL_SHADERS_ATTRIBUTES

This commit is contained in:
enricoturri1966 2022-03-09 08:22:07 +01:00
parent 5ffe010a9d
commit 46283cfde3
37 changed files with 706 additions and 735 deletions

View File

@ -69,7 +69,7 @@
// Enable removal of legacy OpenGL calls // Enable removal of legacy OpenGL calls
#define ENABLE_LEGACY_OPENGL_REMOVAL (1 && ENABLE_2_5_0_ALPHA1) #define ENABLE_LEGACY_OPENGL_REMOVAL (1 && ENABLE_2_5_0_ALPHA1)
// Enable using vertex attributes and matrices in shaders // Enable using vertex attributes and matrices in shaders
#define ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES (1 && ENABLE_LEGACY_OPENGL_REMOVAL) #define ENABLE_GL_SHADERS_ATTRIBUTES (1 && ENABLE_LEGACY_OPENGL_REMOVAL)
// Enable show non-manifold edges // Enable show non-manifold edges
#define ENABLE_SHOW_NON_MANIFOLD_EDGES (1 && ENABLE_2_5_0_ALPHA1) #define ENABLE_SHOW_NON_MANIFOLD_EDGES (1 && ENABLE_2_5_0_ALPHA1)
// Enable rework of Reload from disk command // Enable rework of Reload from disk command

View File

@ -11,10 +11,10 @@
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "GLCanvas3D.hpp" #include "GLCanvas3D.hpp"
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
#include "Plater.hpp" #include "Plater.hpp"
#include "Camera.hpp" #include "Camera.hpp"
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#include <GL/glew.h> #include <GL/glew.h>
@ -109,7 +109,7 @@ const float Bed3D::Axes::DefaultTipLength = 5.0f;
void Bed3D::Axes::render() void Bed3D::Axes::render()
{ {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
auto render_axis = [this](GLShaderProgram* shader, const Transform3d& transform) { auto render_axis = [this](GLShaderProgram* shader, const Transform3d& transform) {
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Transform3d matrix = camera.get_view_matrix() * transform; const Transform3d matrix = camera.get_view_matrix() * transform;
@ -120,21 +120,21 @@ void Bed3D::Axes::render()
auto render_axis = [this](const Transform3f& transform) { auto render_axis = [this](const Transform3f& transform) {
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glMultMatrixf(transform.data())); glsafe(::glMultMatrixf(transform.data()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_arrow.render(); m_arrow.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
}; };
if (!m_arrow.is_initialized()) if (!m_arrow.is_initialized())
m_arrow.init_from(stilized_arrow(16, DefaultTipRadius, DefaultTipLength, DefaultStemRadius, m_stem_length)); m_arrow.init_from(stilized_arrow(16, DefaultTipRadius, DefaultTipLength, DefaultStemRadius, m_stem_length));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -149,11 +149,11 @@ void Bed3D::Axes::render()
#else #else
m_arrow.set_color(-1, ColorRGBA::X()); m_arrow.set_color(-1, ColorRGBA::X());
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_axis(shader, Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0 })); render_axis(shader, Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0 }));
#else #else
render_axis(Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0 }).cast<float>()); render_axis(Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0 }).cast<float>());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// y axis // y axis
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
@ -161,11 +161,11 @@ void Bed3D::Axes::render()
#else #else
m_arrow.set_color(-1, ColorRGBA::Y()); m_arrow.set_color(-1, ColorRGBA::Y());
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_axis(shader, Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0 })); render_axis(shader, Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0 }));
#else #else
render_axis(Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0 }).cast<float>()); render_axis(Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0 }).cast<float>());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// z axis // z axis
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
@ -173,11 +173,11 @@ void Bed3D::Axes::render()
#else #else
m_arrow.set_color(-1, ColorRGBA::Z()); m_arrow.set_color(-1, ColorRGBA::Z());
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_axis(shader, Geometry::assemble_transform(m_origin)); render_axis(shader, Geometry::assemble_transform(m_origin));
#else #else
render_axis(Geometry::assemble_transform(m_origin).cast<float>()); render_axis(Geometry::assemble_transform(m_origin).cast<float>());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
shader->stop_using(); shader->stop_using();
@ -270,7 +270,7 @@ Point Bed3D::point_projection(const Point& point) const
return m_polygon.point_projection(point); return m_polygon.point_projection(point);
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void Bed3D::render(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor, bool show_axes, bool show_texture) void Bed3D::render(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor, bool show_axes, bool show_texture)
{ {
render_internal(canvas, view_matrix, projection_matrix, bottom, scale_factor, show_axes, show_texture, false); render_internal(canvas, view_matrix, projection_matrix, bottom, scale_factor, show_axes, show_texture, false);
@ -290,15 +290,15 @@ void Bed3D::render_for_picking(GLCanvas3D& canvas, bool bottom, float scale_fact
{ {
render_internal(canvas, bottom, scale_factor, false, false, true); render_internal(canvas, bottom, scale_factor, false, false, true);
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void Bed3D::render_internal(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor, void Bed3D::render_internal(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor,
bool show_axes, bool show_texture, bool picking) bool show_axes, bool show_texture, bool picking)
#else #else
void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor, void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
bool show_axes, bool show_texture, bool picking) bool show_axes, bool show_texture, bool picking)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
m_scale_factor = scale_factor; m_scale_factor = scale_factor;
@ -315,7 +315,7 @@ void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
switch (m_type) switch (m_type)
{ {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
case Type::System: { render_system(canvas, view_matrix, projection_matrix, bottom, show_texture); break; } case Type::System: { render_system(canvas, view_matrix, projection_matrix, bottom, show_texture); break; }
default: default:
case Type::Custom: { render_custom(canvas, view_matrix, projection_matrix, bottom, show_texture, picking); break; } case Type::Custom: { render_custom(canvas, view_matrix, projection_matrix, bottom, show_texture, picking); break; }
@ -323,7 +323,7 @@ void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
case Type::System: { render_system(canvas, bottom, show_texture); break; } case Type::System: { render_system(canvas, bottom, show_texture); break; }
default: default:
case Type::Custom: { render_custom(canvas, bottom, show_texture, picking); break; } case Type::Custom: { render_custom(canvas, bottom, show_texture, picking); break; }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
@ -515,7 +515,7 @@ void Bed3D::render_axes()
m_axes.render(); m_axes.render();
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void Bed3D::render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture) void Bed3D::render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture)
{ {
if (!bottom) if (!bottom)
@ -533,7 +533,7 @@ void Bed3D::render_system(GLCanvas3D& canvas, bool bottom, bool show_texture)
if (show_texture) if (show_texture)
render_texture(bottom, canvas); render_texture(bottom, canvas);
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
{ {
@ -599,18 +599,18 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
init_triangles(); init_triangles();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("printbed_attr"); GLShaderProgram* shader = wxGetApp().get_shader("printbed_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("printbed"); GLShaderProgram* shader = wxGetApp().get_shader("printbed");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
shader->set_uniform("transparent_background", bottom); shader->set_uniform("transparent_background", bottom);
shader->set_uniform("svg_source", boost::algorithm::iends_with(m_texture.get_source(), ".svg")); shader->set_uniform("svg_source", boost::algorithm::iends_with(m_texture.get_source(), ".svg"));
@ -704,11 +704,11 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void Bed3D::render_model(const Transform3d& view_matrix, const Transform3d& projection_matrix) void Bed3D::render_model(const Transform3d& view_matrix, const Transform3d& projection_matrix)
#else #else
void Bed3D::render_model() void Bed3D::render_model()
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
if (m_model_filename.empty()) if (m_model_filename.empty())
return; return;
@ -728,15 +728,15 @@ void Bed3D::render_model()
} }
if (!m_model.get_filename().empty()) { if (!m_model.get_filename().empty()) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
shader->set_uniform("emission_factor", 0.0f); shader->set_uniform("emission_factor", 0.0f);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d matrix = view_matrix * Geometry::assemble_transform(m_model_offset); const Transform3d matrix = view_matrix * Geometry::assemble_transform(m_model_offset);
shader->set_uniform("view_model_matrix", matrix); shader->set_uniform("view_model_matrix", matrix);
shader->set_uniform("projection_matrix", projection_matrix); shader->set_uniform("projection_matrix", projection_matrix);
@ -744,21 +744,21 @@ void Bed3D::render_model()
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glTranslated(m_model_offset.x(), m_model_offset.y(), m_model_offset.z())); glsafe(::glTranslated(m_model_offset.x(), m_model_offset.y(), m_model_offset.z()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_model.render(); m_model.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
shader->stop_using(); shader->stop_using();
} }
} }
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void Bed3D::render_custom(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture, bool picking) void Bed3D::render_custom(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture, bool picking)
#else #else
void Bed3D::render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking) void Bed3D::render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
if (m_texture_filename.empty() && m_model_filename.empty()) { if (m_texture_filename.empty() && m_model_filename.empty()) {
render_default(bottom, picking); render_default(bottom, picking);
@ -766,11 +766,11 @@ void Bed3D::render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bo
} }
if (!bottom) if (!bottom)
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_model(view_matrix, projection_matrix); render_model(view_matrix, projection_matrix);
#else #else
render_model(); render_model();
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (show_texture) if (show_texture)
render_texture(bottom, canvas); render_texture(bottom, canvas);
@ -784,19 +784,19 @@ void Bed3D::render_default(bool bottom, bool picking)
init_gridlines(); init_gridlines();
init_triangles(); init_triangles();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
glsafe(::glEnable(GL_BLEND)); glsafe(::glEnable(GL_BLEND));

View File

@ -139,13 +139,13 @@ public:
bool contains(const Point& point) const; bool contains(const Point& point) const;
Point point_projection(const Point& point) const; Point point_projection(const Point& point) const;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void render(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor, bool show_axes, bool show_texture); void render(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor, bool show_axes, bool show_texture);
void render_for_picking(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor); void render_for_picking(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor);
#else #else
void render(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes, bool show_texture); void render(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes, bool show_texture);
void render_for_picking(GLCanvas3D& canvas, bool bottom, float scale_factor); void render_for_picking(GLCanvas3D& canvas, bool bottom, float scale_factor);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
private: private:
// Calculate an extended bounding box from axes and current model for visualization purposes. // Calculate an extended bounding box from axes and current model for visualization purposes.
@ -158,27 +158,27 @@ private:
void calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox); void calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox);
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
static std::tuple<Type, std::string, std::string> detect_type(const Pointfs& shape); static std::tuple<Type, std::string, std::string> detect_type(const Pointfs& shape);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void render_internal(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor, void render_internal(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, float scale_factor,
bool show_axes, bool show_texture, bool picking); bool show_axes, bool show_texture, bool picking);
#else #else
void render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor, void render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
bool show_axes, bool show_texture, bool picking); bool show_axes, bool show_texture, bool picking);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void render_axes(); void render_axes();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture); void render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture);
#else #else
void render_system(GLCanvas3D& canvas, bool bottom, bool show_texture); void render_system(GLCanvas3D& canvas, bool bottom, bool show_texture);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void render_texture(bool bottom, GLCanvas3D& canvas); void render_texture(bool bottom, GLCanvas3D& canvas);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void render_model(const Transform3d& view_matrix, const Transform3d& projection_matrix); void render_model(const Transform3d& view_matrix, const Transform3d& projection_matrix);
void render_custom(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture, bool picking); void render_custom(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture, bool picking);
#else #else
void render_model(); void render_model();
void render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking); void render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void render_default(bool bottom, bool picking); void render_default(bool bottom, bool picking);
#if !ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_LEGACY_OPENGL_REMOVAL
void release_VBOs(); void release_VBOs();

View File

@ -13,9 +13,9 @@
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "Plater.hpp" #include "Plater.hpp"
#include "BitmapCache.hpp" #include "BitmapCache.hpp"
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
#include "Camera.hpp" #include "Camera.hpp"
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#include "libslic3r/BuildVolume.hpp" #include "libslic3r/BuildVolume.hpp"
#include "libslic3r/ExtrusionEntity.hpp" #include "libslic3r/ExtrusionEntity.hpp"
@ -301,7 +301,7 @@ void GLVolume::SinkingContours::render()
{ {
update(); update();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader(); GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -312,11 +312,11 @@ void GLVolume::SinkingContours::render()
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glTranslated(m_shift.x(), m_shift.y(), m_shift.z())); glsafe(::glTranslated(m_shift.x(), m_shift.y(), m_shift.z()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_model.render(); m_model.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
void GLVolume::SinkingContours::update() void GLVolume::SinkingContours::update()
@ -390,7 +390,7 @@ void GLVolume::NonManifoldEdges::render()
update(); update();
glsafe(::glLineWidth(2.0f)); glsafe(::glLineWidth(2.0f));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader(); GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -401,16 +401,16 @@ void GLVolume::NonManifoldEdges::render()
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glMultMatrixd(m_parent.world_matrix().data())); glsafe(::glMultMatrixd(m_parent.world_matrix().data()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
m_model.set_color(complementary(m_parent.render_color)); m_model.set_color(complementary(m_parent.render_color));
#else #else
m_model.set_color(-1, complementary(m_parent.render_color)); m_model.set_color(-1, complementary(m_parent.render_color));
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
m_model.render(); m_model.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
void GLVolume::NonManifoldEdges::update() void GLVolume::NonManifoldEdges::update()
@ -705,19 +705,19 @@ void GLVolume::render()
if (!is_active) if (!is_active)
return; return;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader(); GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
if (shader == nullptr) if (shader == nullptr)
return; return;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (this->is_left_handed()) if (this->is_left_handed())
glFrontFace(GL_CW); glFrontFace(GL_CW);
glsafe(::glCullFace(GL_BACK)); glsafe(::glCullFace(GL_BACK));
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glMultMatrixd(world_matrix().data())); glsafe(::glMultMatrixd(world_matrix().data()));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
if (tverts_range == std::make_pair<size_t, size_t>(0, -1)) if (tverts_range == std::make_pair<size_t, size_t>(0, -1))
@ -728,9 +728,9 @@ void GLVolume::render()
this->indexed_vertex_array.render(this->tverts_range, this->qverts_range); this->indexed_vertex_array.render(this->tverts_range, this->qverts_range);
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
if (this->is_left_handed()) if (this->is_left_handed())
glFrontFace(GL_CCW); glFrontFace(GL_CCW);
@ -1072,12 +1072,12 @@ GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCo
return list; return list;
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, const Transform3d& projection_matrix, void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, const Transform3d& projection_matrix,
std::function<bool(const GLVolume&)> filter_func) const std::function<bool(const GLVolume&)> filter_func) const
#else #else
void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func) const void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func) const
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func); GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func);
if (to_render.empty()) if (to_render.empty())
@ -1088,14 +1088,14 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
return; return;
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat_attr"); GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat_attr");
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat_attr"); GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat_attr");
assert(boost::algorithm::iends_with(shader->get_name(), "_attr")); assert(boost::algorithm::iends_with(shader->get_name(), "_attr"));
#else #else
GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat"); GLShaderProgram* sink_shader = GUI::wxGetApp().get_shader("flat");
GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat"); GLShaderProgram* edges_shader = GUI::wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
if (type == ERenderType::Transparent) { if (type == ERenderType::Transparent) {
@ -1134,17 +1134,11 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
shader->start_using(); shader->start_using();
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//#if ENABLE_LEGACY_OPENGL_REMOVAL
// if (!volume.first->model.is_initialized())
//#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
// shader->set_uniform("uniform_color", volume.first->render_color);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
shader->set_uniform("z_range", m_z_range, 2); shader->set_uniform("z_range", m_z_range, 2);
shader->set_uniform("clipping_plane", m_clipping_plane, 4); shader->set_uniform("clipping_plane", m_clipping_plane, 4);
shader->set_uniform("print_volume.type", static_cast<int>(m_print_volume.type)); shader->set_uniform("print_volume.type", static_cast<int>(m_print_volume.type));
@ -1167,12 +1161,12 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
volume.first->model.set_color(volume.first->render_color); volume.first->model.set_color(volume.first->render_color);
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d matrix = view_matrix * volume.first->world_matrix(); const Transform3d matrix = view_matrix * volume.first->world_matrix();
shader->set_uniform("view_model_matrix", matrix); shader->set_uniform("view_model_matrix", matrix);
shader->set_uniform("projection_matrix", projection_matrix); shader->set_uniform("projection_matrix", projection_matrix);
shader->set_uniform("normal_matrix", (Matrix3d)matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); shader->set_uniform("normal_matrix", (Matrix3d)matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
volume.first->render(); volume.first->render();
#if ENABLE_ENVIRONMENT_MAP #if ENABLE_ENVIRONMENT_MAP
@ -1183,10 +1177,10 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
glsafe(::glDisableClientState(GL_NORMAL_ARRAY)); glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
if (m_show_sinking_contours) { if (m_show_sinking_contours) {

View File

@ -687,12 +687,12 @@ public:
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
// Render the volumes by OpenGL. // Render the volumes by OpenGL.
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, const Transform3d& projection_matrix, void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, const Transform3d& projection_matrix,
std::function<bool(const GLVolume&)> filter_func = std::function<bool(const GLVolume&)>()) const; std::function<bool(const GLVolume&)> filter_func = std::function<bool(const GLVolume&)>()) const;
#else #else
void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func = std::function<bool(const GLVolume&)>()) const; void render(ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func = std::function<bool(const GLVolume&)>()) const;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if !ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_LEGACY_OPENGL_REMOVAL
// Finalize the initialization of the geometry & indices, // Finalize the initialization of the geometry & indices,

View File

@ -184,11 +184,11 @@ void GCodeViewer::COG::render()
init(); init();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("toolpaths_cog_attr"); GLShaderProgram* shader = wxGetApp().get_shader("toolpaths_cog_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("toolpaths_cog"); GLShaderProgram* shader = wxGetApp().get_shader("toolpaths_cog");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -196,7 +196,7 @@ void GCodeViewer::COG::render()
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
Transform3d matrix = camera.get_view_matrix() * Geometry::assemble_transform(cog()); Transform3d matrix = camera.get_view_matrix() * Geometry::assemble_transform(cog());
if (m_fixed_size) { if (m_fixed_size) {
@ -217,7 +217,7 @@ void GCodeViewer::COG::render()
} }
m_model.render(); m_model.render();
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
shader->stop_using(); shader->stop_using();
@ -331,11 +331,11 @@ void GCodeViewer::SequentialView::Marker::render()
if (!m_visible) if (!m_visible)
return; return;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -344,7 +344,7 @@ void GCodeViewer::SequentialView::Marker::render()
shader->start_using(); shader->start_using();
shader->set_uniform("emission_factor", 0.0f); shader->set_uniform("emission_factor", 0.0f);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Transform3d matrix = camera.get_view_matrix() * m_world_transform.cast<double>(); const Transform3d matrix = camera.get_view_matrix() * m_world_transform.cast<double>();
shader->set_uniform("view_model_matrix", matrix); shader->set_uniform("view_model_matrix", matrix);
@ -353,13 +353,13 @@ void GCodeViewer::SequentialView::Marker::render()
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glMultMatrixf(m_world_transform.data())); glsafe(::glMultMatrixf(m_world_transform.data()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_model.render(); m_model.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
shader->stop_using(); shader->stop_using();
@ -692,11 +692,11 @@ void GCodeViewer::init()
#if !DISABLE_GCODEVIEWER_INSTANCED_MODELS #if !DISABLE_GCODEVIEWER_INSTANCED_MODELS
if (wxGetApp().is_gl_version_greater_or_equal_to(3, 3)) { if (wxGetApp().is_gl_version_greater_or_equal_to(3, 3)) {
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::InstancedModel; buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::InstancedModel;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
buffer.shader = "gouraud_light_instanced_attr"; buffer.shader = "gouraud_light_instanced_attr";
#else #else
buffer.shader = "gouraud_light_instanced"; buffer.shader = "gouraud_light_instanced";
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
buffer.model.model.init_from(diamond(16)); buffer.model.model.init_from(diamond(16));
buffer.model.color = option_color(type); buffer.model.color = option_color(type);
buffer.model.instances.format = InstanceVBuffer::EFormat::InstancedModel; buffer.model.instances.format = InstanceVBuffer::EFormat::InstancedModel;
@ -705,11 +705,11 @@ void GCodeViewer::init()
#endif // !DISABLE_GCODEVIEWER_INSTANCED_MODELS #endif // !DISABLE_GCODEVIEWER_INSTANCED_MODELS
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::BatchedModel; buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::BatchedModel;
buffer.vertices.format = VBuffer::EFormat::PositionNormal3; buffer.vertices.format = VBuffer::EFormat::PositionNormal3;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
buffer.shader = "gouraud_light_attr"; buffer.shader = "gouraud_light_attr";
#else #else
buffer.shader = "gouraud_light"; buffer.shader = "gouraud_light";
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
buffer.model.data = diamond(16); buffer.model.data = diamond(16);
buffer.model.color = option_color(type); buffer.model.color = option_color(type);
@ -723,22 +723,22 @@ void GCodeViewer::init()
case EMoveType::Extrude: { case EMoveType::Extrude: {
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Triangle; buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Triangle;
buffer.vertices.format = VBuffer::EFormat::PositionNormal3; buffer.vertices.format = VBuffer::EFormat::PositionNormal3;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
buffer.shader = "gouraud_light_attr"; buffer.shader = "gouraud_light_attr";
#else #else
buffer.shader = "gouraud_light"; buffer.shader = "gouraud_light";
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
break; break;
} }
case EMoveType::Travel: { case EMoveType::Travel: {
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Line; buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Line;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
buffer.vertices.format = VBuffer::EFormat::Position; buffer.vertices.format = VBuffer::EFormat::Position;
buffer.shader = "flat_attr"; buffer.shader = "flat_attr";
#else #else
buffer.vertices.format = VBuffer::EFormat::PositionNormal3; buffer.vertices.format = VBuffer::EFormat::PositionNormal3;
buffer.shader = "toolpaths_lines"; buffer.shader = "toolpaths_lines";
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
break; break;
} }
} }
@ -1324,14 +1324,14 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
// format data into the buffers to be rendered as lines // format data into the buffers to be rendered as lines
auto add_vertices_as_line = [](const GCodeProcessorResult::MoveVertex& prev, const GCodeProcessorResult::MoveVertex& curr, VertexBuffer& vertices) { auto add_vertices_as_line = [](const GCodeProcessorResult::MoveVertex& prev, const GCodeProcessorResult::MoveVertex& curr, VertexBuffer& vertices) {
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
// x component of the normal to the current segment (the normal is parallel to the XY plane) // x component of the normal to the current segment (the normal is parallel to the XY plane)
const Vec3f dir = (curr.position - prev.position).normalized(); const Vec3f dir = (curr.position - prev.position).normalized();
Vec3f normal(dir.y(), -dir.x(), 0.0); Vec3f normal(dir.y(), -dir.x(), 0.0);
normal.normalize(); normal.normalize();
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
auto add_vertex = [&vertices](const GCodeProcessorResult::MoveVertex& vertex) { auto add_vertex = [&vertices](const GCodeProcessorResult::MoveVertex& vertex) {
// add position // add position
vertices.push_back(vertex.position.x()); vertices.push_back(vertex.position.x());
@ -1349,7 +1349,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
vertices.push_back(normal.y()); vertices.push_back(normal.y());
vertices.push_back(normal.z()); vertices.push_back(normal.z());
}; };
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// add previous vertex // add previous vertex
add_vertex(prev); add_vertex(prev);
@ -2973,9 +2973,9 @@ void GCodeViewer::render_toolpaths()
#else #else
const float point_size = 0.8f; const float point_size = 0.8f;
#endif // ENABLE_FIXED_SCREEN_SIZE_POINT_MARKERS #endif // ENABLE_FIXED_SCREEN_SIZE_POINT_MARKERS
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
const std::array<float, 4> light_intensity = { 0.25f, 0.70f, 0.75f, 0.75f }; const std::array<float, 4> light_intensity = { 0.25f, 0.70f, 0.75f, 0.75f };
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const double zoom = camera.get_zoom(); const double zoom = camera.get_zoom();
const std::array<int, 4>& viewport = camera.get_viewport(); const std::array<int, 4>& viewport = camera.get_viewport();
@ -3019,11 +3019,11 @@ void GCodeViewer::render_toolpaths()
glsafe(::glDisable(GL_VERTEX_PROGRAM_POINT_SIZE)); glsafe(::glDisable(GL_VERTEX_PROGRAM_POINT_SIZE));
}; };
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
auto shader_init_as_lines = [light_intensity](GLShaderProgram &shader) { auto shader_init_as_lines = [light_intensity](GLShaderProgram &shader) {
shader.set_uniform("light_intensity", light_intensity); shader.set_uniform("light_intensity", light_intensity);
}; };
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
auto render_as_lines = [ auto render_as_lines = [
#if ENABLE_GCODE_VIEWER_STATISTICS #if ENABLE_GCODE_VIEWER_STATISTICS
this this
@ -3088,7 +3088,7 @@ void GCodeViewer::render_toolpaths()
} }
}; };
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_GCODE_VIEWER_STATISTICS #if ENABLE_GCODE_VIEWER_STATISTICS
auto render_as_batched_model = [this](TBuffer& buffer, GLShaderProgram& shader, int position_id, int normal_id) { auto render_as_batched_model = [this](TBuffer& buffer, GLShaderProgram& shader, int position_id, int normal_id) {
#else #else
@ -3100,7 +3100,7 @@ void GCodeViewer::render_toolpaths()
#else #else
auto render_as_batched_model = [](TBuffer& buffer, GLShaderProgram& shader) { auto render_as_batched_model = [](TBuffer& buffer, GLShaderProgram& shader) {
#endif // ENABLE_GCODE_VIEWER_STATISTICS #endif // ENABLE_GCODE_VIEWER_STATISTICS
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
struct Range struct Range
{ {
@ -3115,7 +3115,7 @@ void GCodeViewer::render_toolpaths()
const IBuffer& i_buffer = buffer.indices[j]; const IBuffer& i_buffer = buffer.indices[j];
buffer_range.last = buffer_range.first + i_buffer.count / indices_per_instance; buffer_range.last = buffer_range.first + i_buffer.count / indices_per_instance;
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, i_buffer.vbo)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, i_buffer.vbo));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (position_id != -1) { if (position_id != -1) {
glsafe(::glVertexAttribPointer(position_id, buffer.vertices.position_size_floats(), GL_FLOAT, GL_FALSE, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes())); glsafe(::glVertexAttribPointer(position_id, buffer.vertices.position_size_floats(), GL_FLOAT, GL_FALSE, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes()));
glsafe(::glEnableVertexAttribArray(position_id)); glsafe(::glEnableVertexAttribArray(position_id));
@ -3123,10 +3123,10 @@ void GCodeViewer::render_toolpaths()
#else #else
glsafe(::glVertexPointer(buffer.vertices.position_size_floats(), GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes())); glsafe(::glVertexPointer(buffer.vertices.position_size_floats(), GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes()));
glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
const bool has_normals = buffer.vertices.normal_size_floats() > 0; const bool has_normals = buffer.vertices.normal_size_floats() > 0;
if (has_normals) { if (has_normals) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (normal_id != -1) { if (normal_id != -1) {
glsafe(::glVertexAttribPointer(normal_id, buffer.vertices.normal_size_floats(), GL_FLOAT, GL_FALSE, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes())); glsafe(::glVertexAttribPointer(normal_id, buffer.vertices.normal_size_floats(), GL_FLOAT, GL_FALSE, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes()));
glsafe(::glEnableVertexAttribArray(normal_id)); glsafe(::glEnableVertexAttribArray(normal_id));
@ -3134,7 +3134,7 @@ void GCodeViewer::render_toolpaths()
#else #else
glsafe(::glNormalPointer(GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes())); glsafe(::glNormalPointer(GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes()));
glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, i_buffer.ibo)); glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, i_buffer.ibo));
@ -3158,7 +3158,7 @@ void GCodeViewer::render_toolpaths()
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (normal_id != -1) if (normal_id != -1)
glsafe(::glDisableVertexAttribArray(normal_id)); glsafe(::glDisableVertexAttribArray(normal_id));
if (position_id != -1) if (position_id != -1)
@ -3168,7 +3168,7 @@ void GCodeViewer::render_toolpaths()
glsafe(::glDisableClientState(GL_NORMAL_ARRAY)); glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
buffer_range.first = buffer_range.last; buffer_range.first = buffer_range.last;
@ -3193,7 +3193,7 @@ void GCodeViewer::render_toolpaths()
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
int position_id = -1; int position_id = -1;
int normal_id = -1; int normal_id = -1;
const Transform3d& view_matrix = camera.get_view_matrix(); const Transform3d& view_matrix = camera.get_view_matrix();
@ -3203,7 +3203,7 @@ void GCodeViewer::render_toolpaths()
position_id = shader->get_attrib_location("v_position"); position_id = shader->get_attrib_location("v_position");
normal_id = shader->get_attrib_location("v_normal"); normal_id = shader->get_attrib_location("v_normal");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::InstancedModel) { if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::InstancedModel) {
shader->set_uniform("emission_factor", 0.25f); shader->set_uniform("emission_factor", 0.25f);
@ -3212,15 +3212,15 @@ void GCodeViewer::render_toolpaths()
} }
else if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::BatchedModel) { else if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::BatchedModel) {
shader->set_uniform("emission_factor", 0.25f); shader->set_uniform("emission_factor", 0.25f);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_as_batched_model(buffer, *shader, position_id, normal_id); render_as_batched_model(buffer, *shader, position_id, normal_id);
#else #else
render_as_batched_model(buffer, *shader); render_as_batched_model(buffer, *shader);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
shader->set_uniform("emission_factor", 0.0f); shader->set_uniform("emission_factor", 0.0f);
} }
else { else {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Point) if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Point)
shader_init_as_points(*shader); shader_init_as_points(*shader);
#else #else
@ -3229,7 +3229,7 @@ void GCodeViewer::render_toolpaths()
case TBuffer::ERenderPrimitiveType::Line: shader_init_as_lines(*shader); break; case TBuffer::ERenderPrimitiveType::Line: shader_init_as_lines(*shader); break;
default: break; default: break;
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
const int uniform_color = shader->get_uniform_location("uniform_color"); const int uniform_color = shader->get_uniform_location("uniform_color");
auto it_path = buffer.render_paths.begin(); auto it_path = buffer.render_paths.begin();
@ -3242,7 +3242,7 @@ void GCodeViewer::render_toolpaths()
continue; continue;
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, i_buffer.vbo)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, i_buffer.vbo));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (position_id != -1) { if (position_id != -1) {
glsafe(::glVertexAttribPointer(position_id, buffer.vertices.position_size_floats(), GL_FLOAT, GL_FALSE, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes())); glsafe(::glVertexAttribPointer(position_id, buffer.vertices.position_size_floats(), GL_FLOAT, GL_FALSE, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes()));
glsafe(::glEnableVertexAttribArray(position_id)); glsafe(::glEnableVertexAttribArray(position_id));
@ -3250,10 +3250,10 @@ void GCodeViewer::render_toolpaths()
#else #else
glsafe(::glVertexPointer(buffer.vertices.position_size_floats(), GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes())); glsafe(::glVertexPointer(buffer.vertices.position_size_floats(), GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes()));
glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
const bool has_normals = buffer.vertices.normal_size_floats() > 0; const bool has_normals = buffer.vertices.normal_size_floats() > 0;
if (has_normals) { if (has_normals) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (normal_id != -1) { if (normal_id != -1) {
glsafe(::glVertexAttribPointer(normal_id, buffer.vertices.normal_size_floats(), GL_FLOAT, GL_FALSE, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes())); glsafe(::glVertexAttribPointer(normal_id, buffer.vertices.normal_size_floats(), GL_FLOAT, GL_FALSE, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes()));
glsafe(::glEnableVertexAttribArray(normal_id)); glsafe(::glEnableVertexAttribArray(normal_id));
@ -3261,7 +3261,7 @@ void GCodeViewer::render_toolpaths()
#else #else
glsafe(::glNormalPointer(GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes())); glsafe(::glNormalPointer(GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes()));
glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, i_buffer.ibo)); glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, i_buffer.ibo));
@ -3287,7 +3287,7 @@ void GCodeViewer::render_toolpaths()
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (normal_id != -1) if (normal_id != -1)
glsafe(::glDisableVertexAttribArray(normal_id)); glsafe(::glDisableVertexAttribArray(normal_id));
if (position_id != -1) if (position_id != -1)
@ -3297,7 +3297,7 @@ void GCodeViewer::render_toolpaths()
glsafe(::glDisableClientState(GL_NORMAL_ARRAY)); glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
} }
} }
@ -3318,7 +3318,7 @@ void GCodeViewer::render_toolpaths()
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
int position_id = -1; int position_id = -1;
int normal_id = -1; int normal_id = -1;
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
@ -3329,10 +3329,10 @@ void GCodeViewer::render_toolpaths()
position_id = shader->get_attrib_location("v_position"); position_id = shader->get_attrib_location("v_position");
normal_id = shader->get_attrib_location("v_normal"); normal_id = shader->get_attrib_location("v_normal");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, cap.vbo)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, cap.vbo));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (position_id != -1) { if (position_id != -1) {
glsafe(::glVertexAttribPointer(position_id, buffer->vertices.position_size_floats(), GL_FLOAT, GL_FALSE, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.position_offset_bytes())); glsafe(::glVertexAttribPointer(position_id, buffer->vertices.position_size_floats(), GL_FLOAT, GL_FALSE, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.position_offset_bytes()));
glsafe(::glEnableVertexAttribArray(position_id)); glsafe(::glEnableVertexAttribArray(position_id));
@ -3340,10 +3340,10 @@ void GCodeViewer::render_toolpaths()
#else #else
glsafe(::glVertexPointer(buffer->vertices.position_size_floats(), GL_FLOAT, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.position_offset_bytes())); glsafe(::glVertexPointer(buffer->vertices.position_size_floats(), GL_FLOAT, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.position_offset_bytes()));
glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
const bool has_normals = buffer->vertices.normal_size_floats() > 0; const bool has_normals = buffer->vertices.normal_size_floats() > 0;
if (has_normals) { if (has_normals) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (normal_id != -1) { if (normal_id != -1) {
glsafe(::glVertexAttribPointer(normal_id, buffer->vertices.normal_size_floats(), GL_FLOAT, GL_FALSE, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.normal_offset_bytes())); glsafe(::glVertexAttribPointer(normal_id, buffer->vertices.normal_size_floats(), GL_FLOAT, GL_FALSE, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.normal_offset_bytes()));
glsafe(::glEnableVertexAttribArray(normal_id)); glsafe(::glEnableVertexAttribArray(normal_id));
@ -3351,7 +3351,7 @@ void GCodeViewer::render_toolpaths()
#else #else
glsafe(::glNormalPointer(GL_FLOAT, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.normal_offset_bytes())); glsafe(::glNormalPointer(GL_FLOAT, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.normal_offset_bytes()));
glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
shader->set_uniform("uniform_color", cap.color); shader->set_uniform("uniform_color", cap.color);
@ -3364,7 +3364,7 @@ void GCodeViewer::render_toolpaths()
++m_statistics.gl_triangles_calls_count; ++m_statistics.gl_triangles_calls_count;
#endif // ENABLE_GCODE_VIEWER_STATISTICS #endif // ENABLE_GCODE_VIEWER_STATISTICS
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (normal_id != -1) if (normal_id != -1)
glsafe(::glDisableVertexAttribArray(normal_id)); glsafe(::glDisableVertexAttribArray(normal_id));
if (position_id != -1) if (position_id != -1)
@ -3374,7 +3374,7 @@ void GCodeViewer::render_toolpaths()
glsafe(::glDisableClientState(GL_NORMAL_ARRAY)); glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
@ -3392,11 +3392,11 @@ void GCodeViewer::render_shells()
if (!m_shells.visible || m_shells.volumes.empty()) if (!m_shells.visible || m_shells.volumes.empty())
return; return;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -3413,12 +3413,12 @@ void GCodeViewer::render_shells()
// glsafe(::glDepthMask(GL_FALSE)); // glsafe(::glDepthMask(GL_FALSE));
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
m_shells.volumes.render(GLVolumeCollection::ERenderType::Transparent, true, camera.get_view_matrix(), camera.get_projection_matrix()); m_shells.volumes.render(GLVolumeCollection::ERenderType::Transparent, true, camera.get_view_matrix(), camera.get_projection_matrix());
#else #else
m_shells.volumes.render(GLVolumeCollection::ERenderType::Transparent, true, wxGetApp().plater()->get_camera().get_view_matrix()); m_shells.volumes.render(GLVolumeCollection::ERenderType::Transparent, true, wxGetApp().plater()->get_camera().get_view_matrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
shader->stop_using(); shader->stop_using();
// glsafe(::glDepthMask(GL_TRUE)); // glsafe(::glDepthMask(GL_TRUE));

View File

@ -263,7 +263,7 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas)
GLCanvas3D::LayersEditing::s_overlay_window_width = ImGui::GetWindowSize().x /*+ (float)m_layers_texture.width/4*/; GLCanvas3D::LayersEditing::s_overlay_window_width = ImGui::GetWindowSize().x /*+ (float)m_layers_texture.width/4*/;
imgui.end(); imgui.end();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_active_object_annotations(canvas); render_active_object_annotations(canvas);
render_profile(canvas); render_profile(canvas);
#else #else
@ -277,7 +277,7 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas)
m_profile.old_bar_rect = bar_rect; m_profile.old_bar_rect = bar_rect;
m_profile.dirty = false; m_profile.dirty = false;
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
float GLCanvas3D::LayersEditing::get_cursor_z_relative(const GLCanvas3D& canvas) float GLCanvas3D::LayersEditing::get_cursor_z_relative(const GLCanvas3D& canvas)
@ -311,7 +311,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_screen(const GLCanvas3D& canvas)
return { w - thickness_bar_width(canvas), 0.0f, w, h }; return { w - thickness_bar_width(canvas), 0.0f, w, h };
} }
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas) Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
{ {
const Size& cnv_size = canvas.get_canvas_size(); const Size& cnv_size = canvas.get_canvas_size();
@ -320,7 +320,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom(); float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
return { (half_w - thickness_bar_width(canvas)) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom }; return { (half_w - thickness_bar_width(canvas)) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom };
} }
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
bool GLCanvas3D::LayersEditing::is_initialized() const bool GLCanvas3D::LayersEditing::is_initialized() const
{ {
@ -353,13 +353,13 @@ std::string GLCanvas3D::LayersEditing::get_tooltip(const GLCanvas3D& canvas) con
return ret; return ret;
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3D& canvas) void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3D& canvas)
#else #else
void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect) void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Size cnv_size = canvas.get_canvas_size(); const Size cnv_size = canvas.get_canvas_size();
const float cnv_width = (float)cnv_size.get_width(); const float cnv_width = (float)cnv_size.get_width();
const float cnv_height = (float)cnv_size.get_height(); const float cnv_height = (float)cnv_size.get_height();
@ -371,7 +371,7 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height_attr"); GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height"); GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -382,23 +382,23 @@ 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", m_object_max_z * this->get_cursor_z_relative(canvas));
shader->set_uniform("z_cursor_band_width", band_width); shader->set_uniform("z_cursor_band_width", band_width);
shader->set_uniform("object_max_z", m_object_max_z); shader->set_uniform("object_max_z", m_object_max_z);
#if ENABLE_GLBEGIN_GLEND_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());
shader->set_uniform("normal_matrix", (Matrix3d)Eigen::Matrix3d::Identity()); shader->set_uniform("normal_matrix", (Matrix3d)Eigen::Matrix3d::Identity());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
glsafe(::glBindTexture(GL_TEXTURE_2D, m_z_texture_id)); glsafe(::glBindTexture(GL_TEXTURE_2D, m_z_texture_id));
// Render the color bar // Render the color bar
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (!m_profile.background.is_initialized() || m_profile.old_canvas_width != cnv_width) { if (!m_profile.background.is_initialized() || m_profile.old_canvas_width != cnv_width) {
m_profile.old_canvas_width = cnv_width; m_profile.old_canvas_width = cnv_width;
#else #else
if (!m_profile.background.is_initialized() || m_profile.dirty) { if (!m_profile.background.is_initialized() || m_profile.dirty) {
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_profile.background.reset(); m_profile.background.reset();
GLModel::Geometry init_data; GLModel::Geometry init_data;
@ -407,7 +407,7 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
init_data.reserve_indices(6); init_data.reserve_indices(6);
// vertices // vertices
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const float l = 1.0f - 2.0f * THICKNESS_BAR_WIDTH * cnv_inv_width; const float l = 1.0f - 2.0f * THICKNESS_BAR_WIDTH * cnv_inv_width;
const float r = 1.0f; const float r = 1.0f;
const float t = 1.0f; const float t = 1.0f;
@ -417,7 +417,7 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
const float r = bar_rect.get_right(); const float r = bar_rect.get_right();
const float t = bar_rect.get_top(); const float t = bar_rect.get_top();
const float b = bar_rect.get_bottom(); const float b = bar_rect.get_bottom();
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
init_data.add_vertex(Vec2f(l, b), Vec2f(0.0f, 0.0f)); init_data.add_vertex(Vec2f(l, b), Vec2f(0.0f, 0.0f));
init_data.add_vertex(Vec2f(r, b), Vec2f(1.0f, 0.0f)); init_data.add_vertex(Vec2f(r, b), Vec2f(1.0f, 0.0f));
init_data.add_vertex(Vec2f(r, t), Vec2f(1.0f, 1.0f)); init_data.add_vertex(Vec2f(r, t), Vec2f(1.0f, 1.0f));
@ -451,18 +451,18 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
shader->stop_using(); shader->stop_using();
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLCanvas3D::LayersEditing::render_profile(const GLCanvas3D& canvas) void GLCanvas3D::LayersEditing::render_profile(const GLCanvas3D& canvas)
#else #else
void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect) void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
//FIXME show some kind of legend. //FIXME show some kind of legend.
if (!m_slicing_parameters) if (!m_slicing_parameters)
return; return;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Size cnv_size = canvas.get_canvas_size(); const Size cnv_size = canvas.get_canvas_size();
const float cnv_width = (float)cnv_size.get_width(); const float cnv_width = (float)cnv_size.get_width();
const float cnv_height = (float)cnv_size.get_height(); const float cnv_height = (float)cnv_size.get_height();
@ -479,15 +479,15 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
// Make the vertical bar a bit wider so the layer height curve does not touch the edge of the bar region. // Make the vertical bar a bit wider so the layer height curve does not touch the edge of the bar region.
const float scale_x = bar_rect.get_width() / float(1.12 * m_slicing_parameters->max_layer_height); const float scale_x = bar_rect.get_width() / float(1.12 * m_slicing_parameters->max_layer_height);
const float scale_y = bar_rect.get_height() / m_object_max_z; const float scale_y = bar_rect.get_height() / m_object_max_z;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
// Baseline // Baseline
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (!m_profile.baseline.is_initialized() || m_profile.old_layer_height_profile != m_layer_height_profile) { if (!m_profile.baseline.is_initialized() || m_profile.old_layer_height_profile != m_layer_height_profile) {
#else #else
if (!m_profile.baseline.is_initialized() || m_profile.dirty) { if (!m_profile.baseline.is_initialized() || m_profile.dirty) {
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_profile.baseline.reset(); m_profile.baseline.reset();
GLModel::Geometry init_data; GLModel::Geometry init_data;
@ -497,7 +497,7 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
init_data.reserve_indices(2); init_data.reserve_indices(2);
// vertices // vertices
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const float axis_x = 2.0f * ((cnv_width - THICKNESS_BAR_WIDTH + float(m_slicing_parameters->layer_height) * scale_x) * cnv_inv_width - 0.5f); const float axis_x = 2.0f * ((cnv_width - THICKNESS_BAR_WIDTH + float(m_slicing_parameters->layer_height) * scale_x) * cnv_inv_width - 0.5f);
init_data.add_vertex(Vec2f(axis_x, -1.0f)); init_data.add_vertex(Vec2f(axis_x, -1.0f));
init_data.add_vertex(Vec2f(axis_x, 1.0f)); init_data.add_vertex(Vec2f(axis_x, 1.0f));
@ -505,7 +505,7 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
const float x = bar_rect.get_left() + float(m_slicing_parameters->layer_height) * scale_x; const float x = bar_rect.get_left() + float(m_slicing_parameters->layer_height) * scale_x;
init_data.add_vertex(Vec2f(x, bar_rect.get_bottom())); init_data.add_vertex(Vec2f(x, bar_rect.get_bottom()));
init_data.add_vertex(Vec2f(x, bar_rect.get_top())); init_data.add_vertex(Vec2f(x, bar_rect.get_top()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// indices // indices
init_data.add_ushort_line(0, 1); init_data.add_ushort_line(0, 1);
@ -513,11 +513,11 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
m_profile.baseline.init_from(std::move(init_data)); m_profile.baseline.init_from(std::move(init_data));
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (!m_profile.profile.is_initialized() || m_profile.old_layer_height_profile != m_layer_height_profile) { if (!m_profile.profile.is_initialized() || m_profile.old_layer_height_profile != m_layer_height_profile) {
#else #else
if (!m_profile.profile.is_initialized() || m_profile.dirty || m_profile.old_layer_height_profile != m_layer_height_profile) { if (!m_profile.profile.is_initialized() || m_profile.dirty || m_profile.old_layer_height_profile != m_layer_height_profile) {
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_profile.old_layer_height_profile = m_layer_height_profile; m_profile.old_layer_height_profile = m_layer_height_profile;
m_profile.profile.reset(); m_profile.profile.reset();
@ -529,13 +529,13 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
// vertices + indices // vertices + indices
for (unsigned int i = 0; i < (unsigned int)m_layer_height_profile.size(); i += 2) { for (unsigned int i = 0; i < (unsigned int)m_layer_height_profile.size(); i += 2) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
init_data.add_vertex(Vec2f(2.0f * ((cnv_width - THICKNESS_BAR_WIDTH + float(m_layer_height_profile[i + 1]) * scale_x) * cnv_inv_width - 0.5f), init_data.add_vertex(Vec2f(2.0f * ((cnv_width - THICKNESS_BAR_WIDTH + float(m_layer_height_profile[i + 1]) * scale_x) * cnv_inv_width - 0.5f),
2.0f * (float(m_layer_height_profile[i]) * scale_y * cnv_inv_height - 0.5))); 2.0f * (float(m_layer_height_profile[i]) * scale_y * cnv_inv_height - 0.5)));
#else #else
init_data.add_vertex(Vec2f(bar_rect.get_left() + float(m_layer_height_profile[i + 1]) * scale_x, init_data.add_vertex(Vec2f(bar_rect.get_left() + float(m_layer_height_profile[i + 1]) * scale_x,
bar_rect.get_bottom() + float(m_layer_height_profile[i]) * scale_y)); bar_rect.get_bottom() + float(m_layer_height_profile[i]) * scale_y));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (init_data.format.index_type == GLModel::Geometry::EIndexType::USHORT) if (init_data.format.index_type == GLModel::Geometry::EIndexType::USHORT)
init_data.add_ushort_index((unsigned short)i / 2); init_data.add_ushort_index((unsigned short)i / 2);
else else
@ -545,17 +545,17 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
m_profile.profile.init_from(std::move(init_data)); m_profile.profile.init_from(std::move(init_data));
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_profile.baseline.render(); m_profile.baseline.render();
m_profile.profile.render(); m_profile.profile.render();
shader->stop_using(); shader->stop_using();
@ -589,11 +589,11 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
if (current_shader != nullptr) if (current_shader != nullptr)
current_shader->stop_using(); current_shader->stop_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height_attr"); GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height"); GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -607,10 +607,10 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
shader->set_uniform("z_cursor", float(m_object_max_z) * float(this->get_cursor_z_relative(canvas))); 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)); shader->set_uniform("z_cursor_band_width", float(this->band_width));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// Initialize the layer height texture mapping. // Initialize the layer height texture mapping.
const GLsizei w = (GLsizei)m_layers_texture.width; const GLsizei w = (GLsizei)m_layers_texture.width;
@ -630,11 +630,11 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
shader->set_uniform("volume_world_matrix", glvolume->world_matrix()); shader->set_uniform("volume_world_matrix", glvolume->world_matrix());
shader->set_uniform("object_max_z", 0.0f); shader->set_uniform("object_max_z", 0.0f);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d view_model_matrix = camera.get_view_matrix() * glvolume->world_matrix(); const Transform3d view_model_matrix = camera.get_view_matrix() * glvolume->world_matrix();
shader->set_uniform("view_model_matrix", view_model_matrix); shader->set_uniform("view_model_matrix", view_model_matrix);
shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glvolume->render(); glvolume->render();
} }
@ -1070,11 +1070,11 @@ void GLCanvas3D::SequentialPrintClearance::render()
const ColorRGBA NO_FILL_COLOR = { 1.0f, 1.0f, 1.0f, 0.75f }; const ColorRGBA NO_FILL_COLOR = { 1.0f, 1.0f, 1.0f, 0.75f };
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
@ -1083,11 +1083,11 @@ void GLCanvas3D::SequentialPrintClearance::render()
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
glsafe(::glDisable(GL_CULL_FACE)); glsafe(::glDisable(GL_CULL_FACE));
@ -1707,11 +1707,11 @@ void GLCanvas3D::render()
_render_gcode(); _render_gcode();
_render_sla_slices(); _render_sla_slices();
_render_selection(); _render_selection();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
_render_bed(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward(), true); _render_bed(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward(), true);
#else #else
_render_bed(!camera.is_looking_downward(), true); _render_bed(!camera.is_looking_downward(), true);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
_render_objects(GLVolumeCollection::ERenderType::Transparent); _render_objects(GLVolumeCollection::ERenderType::Transparent);
_render_sequential_clearance(); _render_sequential_clearance();
@ -4258,12 +4258,12 @@ bool GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x)
ImGuiWrapper* imgui = wxGetApp().imgui(); ImGuiWrapper* imgui = wxGetApp().imgui();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
imgui->set_next_window_pos(pos_x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f); imgui->set_next_window_pos(pos_x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
#else #else
const float x = pos_x * (float)wxGetApp().plater()->get_camera().get_zoom() + 0.5f * (float)get_canvas_size().get_width(); const float x = pos_x * (float)wxGetApp().plater()->get_camera().get_zoom() + 0.5f * (float)get_canvas_size().get_width();
imgui->set_next_window_pos(x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f); imgui->set_next_window_pos(x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
std::string title = is_undo ? L("Undo History") : L("Redo History"); std::string title = is_undo ? L("Undo History") : L("Redo History");
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
@ -4302,12 +4302,12 @@ bool GLCanvas3D::_render_search_list(float pos_x)
bool action_taken = false; bool action_taken = false;
ImGuiWrapper* imgui = wxGetApp().imgui(); ImGuiWrapper* imgui = wxGetApp().imgui();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
imgui->set_next_window_pos(pos_x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f); imgui->set_next_window_pos(pos_x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
#else #else
const float x = /*pos_x * (float)wxGetApp().plater()->get_camera().get_zoom() + */0.5f * (float)get_canvas_size().get_width(); const float x = /*pos_x * (float)wxGetApp().plater()->get_camera().get_zoom() + */0.5f * (float)get_canvas_size().get_width();
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f); imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
std::string title = L("Search"); std::string title = L("Search");
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
@ -4360,13 +4360,13 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
{ {
ImGuiWrapper *imgui = wxGetApp().imgui(); ImGuiWrapper *imgui = wxGetApp().imgui();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
imgui->set_next_window_pos(pos_x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f); imgui->set_next_window_pos(pos_x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
#else #else
auto canvas_w = float(get_canvas_size().get_width()); auto canvas_w = float(get_canvas_size().get_width());
const float x = pos_x * float(wxGetApp().plater()->get_camera().get_zoom()) + 0.5f * canvas_w; const float x = pos_x * float(wxGetApp().plater()->get_camera().get_zoom()) + 0.5f * canvas_w;
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f); imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
imgui->begin(_L("Arrange options"), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse); imgui->begin(_L("Arrange options"), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
@ -4491,9 +4491,9 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
camera.zoom_to_box(volumes_box); camera.zoom_to_box(volumes_box);
camera.apply_view_matrix(); camera.apply_view_matrix();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d& view_matrix = camera.get_view_matrix(); const Transform3d& view_matrix = camera.get_view_matrix();
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
double near_z = -1.0; double near_z = -1.0;
double far_z = -1.0; double far_z = -1.0;
@ -4502,22 +4502,22 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
// extends the near and far z of the frustrum to avoid the bed being clipped // extends the near and far z of the frustrum to avoid the bed being clipped
// box in eye space // box in eye space
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const BoundingBoxf3 t_bed_box = m_bed.extended_bounding_box().transformed(view_matrix); const BoundingBoxf3 t_bed_box = m_bed.extended_bounding_box().transformed(view_matrix);
#else #else
const BoundingBoxf3 t_bed_box = m_bed.extended_bounding_box().transformed(camera.get_view_matrix()); const BoundingBoxf3 t_bed_box = m_bed.extended_bounding_box().transformed(camera.get_view_matrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
near_z = -t_bed_box.max.z(); near_z = -t_bed_box.max.z();
far_z = -t_bed_box.min.z(); far_z = -t_bed_box.min.z();
} }
camera.apply_projection(volumes_box, near_z, far_z); camera.apply_projection(volumes_box, near_z, far_z);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -4530,9 +4530,9 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
shader->start_using(); shader->start_using();
shader->set_uniform("emission_factor", 0.0f); shader->set_uniform("emission_factor", 0.0f);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d& projection_matrix = camera.get_projection_matrix(); const Transform3d& projection_matrix = camera.get_projection_matrix();
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
for (GLVolume* vol : visible_volumes) { for (GLVolume* vol : visible_volumes) {
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
@ -4543,12 +4543,12 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
// the volume may have been deactivated by an active gizmo // the volume may have been deactivated by an active gizmo
const bool is_active = vol->is_active; const bool is_active = vol->is_active;
vol->is_active = true; vol->is_active = true;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d matrix = view_matrix * vol->world_matrix(); const Transform3d matrix = view_matrix * vol->world_matrix();
shader->set_uniform("view_model_matrix", matrix); shader->set_uniform("view_model_matrix", matrix);
shader->set_uniform("projection_matrix", projection_matrix); shader->set_uniform("projection_matrix", projection_matrix);
shader->set_uniform("normal_matrix", (Matrix3d)matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); shader->set_uniform("normal_matrix", (Matrix3d)matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
vol->render(); vol->render();
vol->is_active = is_active; vol->is_active = is_active;
} }
@ -4558,11 +4558,11 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
if (thumbnail_params.show_bed) if (thumbnail_params.show_bed)
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
_render_bed(view_matrix, projection_matrix, !camera.is_looking_downward(), false); _render_bed(view_matrix, projection_matrix, !camera.is_looking_downward(), false);
#else #else
_render_bed(!camera.is_looking_downward(), false); _render_bed(!camera.is_looking_downward(), false);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// restore background color // restore background color
if (thumbnail_params.transparent_background) if (thumbnail_params.transparent_background)
@ -4823,34 +4823,31 @@ bool GLCanvas3D::_init_main_toolbar()
background_data.right = 16; background_data.right = 16;
background_data.bottom = 16; background_data.bottom = 16;
if (!m_main_toolbar.init(background_data)) if (!m_main_toolbar.init(background_data)) {
{
// unable to init the toolbar texture, disable it // unable to init the toolbar texture, disable it
m_main_toolbar.set_enabled(false); m_main_toolbar.set_enabled(false);
return true; return true;
} }
// init arrow // init arrow
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (!m_main_toolbar.init_arrow("toolbar_arrow_2.svg"))
#else
BackgroundTexture::Metadata arrow_data; BackgroundTexture::Metadata arrow_data;
arrow_data.filename = "toolbar_arrow.svg"; arrow_data.filename = "toolbar_arrow.svg";
arrow_data.left = 0; arrow_data.left = 0;
arrow_data.top = 0; arrow_data.top = 0;
arrow_data.right = 0; arrow_data.right = 0;
arrow_data.bottom = 0; arrow_data.bottom = 0;
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
if (!m_main_toolbar.init_arrow("toolbar_arrow_2.svg"))
#else
if (!m_main_toolbar.init_arrow(arrow_data)) if (!m_main_toolbar.init_arrow(arrow_data))
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
BOOST_LOG_TRIVIAL(error) << "Main toolbar failed to load arrow texture."; BOOST_LOG_TRIVIAL(error) << "Main toolbar failed to load arrow texture.";
// m_gizmos is created at constructor, thus we can init arrow here. // m_gizmos is created at constructor, thus we can init arrow here.
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (!m_gizmos.init_arrow("toolbar_arrow_2.svg")) if (!m_gizmos.init_arrow("toolbar_arrow_2.svg"))
#else #else
if (!m_gizmos.init_arrow(arrow_data)) if (!m_gizmos.init_arrow(arrow_data))
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
BOOST_LOG_TRIVIAL(error) << "Gizmos manager failed to load arrow texture."; BOOST_LOG_TRIVIAL(error) << "Gizmos manager failed to load arrow texture.";
// m_main_toolbar.set_layout_type(GLToolbar::Layout::Vertical); // m_main_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
@ -5055,19 +5052,17 @@ bool GLCanvas3D::_init_undoredo_toolbar()
} }
// init arrow // init arrow
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (!m_undoredo_toolbar.init_arrow("toolbar_arrow_2.svg"))
#else
BackgroundTexture::Metadata arrow_data; BackgroundTexture::Metadata arrow_data;
arrow_data.filename = "toolbar_arrow.svg"; arrow_data.filename = "toolbar_arrow.svg";
arrow_data.left = 0; arrow_data.left = 0;
arrow_data.top = 0; arrow_data.top = 0;
arrow_data.right = 0; arrow_data.right = 0;
arrow_data.bottom = 0; arrow_data.bottom = 0;
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
if (!m_undoredo_toolbar.init_arrow("toolbar_arrow_2.svg"))
#else
if (!m_undoredo_toolbar.init_arrow(arrow_data)) if (!m_undoredo_toolbar.init_arrow(arrow_data))
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
BOOST_LOG_TRIVIAL(error) << "Undo/Redo toolbar failed to load arrow texture."; BOOST_LOG_TRIVIAL(error) << "Undo/Redo toolbar failed to load arrow texture.";
// m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Vertical); // m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
@ -5287,12 +5282,12 @@ void GLCanvas3D::_picking_pass()
if (m_camera_clipping_plane.is_active()) if (m_camera_clipping_plane.is_active())
::glDisable(GL_CLIP_PLANE0); ::glDisable(GL_CLIP_PLANE0);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
_render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward()); _render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward());
#else #else
_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward()); _render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_gizmos.render_current_gizmo_for_picking_pass(); m_gizmos.render_current_gizmo_for_picking_pass();
@ -5348,12 +5343,12 @@ void GLCanvas3D::_rectangular_selection_picking_pass()
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
_render_volumes_for_picking(); _render_volumes_for_picking();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
_render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward()); _render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward());
#else #else
_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward()); _render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (m_multisample_allowed) if (m_multisample_allowed)
glsafe(::glEnable(GL_MULTISAMPLE)); glsafe(::glEnable(GL_MULTISAMPLE));
@ -5426,13 +5421,13 @@ void GLCanvas3D::_render_background()
use_error_color &= m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed(); use_error_color &= m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed();
} }
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glLoadIdentity()); glsafe(::glLoadIdentity());
glsafe(::glMatrixMode(GL_PROJECTION)); glsafe(::glMatrixMode(GL_PROJECTION));
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glLoadIdentity()); glsafe(::glLoadIdentity());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
// Draws a bottom to top gradient over the complete screen. // Draws a bottom to top gradient over the complete screen.
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
@ -5461,11 +5456,11 @@ void GLCanvas3D::_render_background()
m_background.init_from(std::move(init_data)); m_background.init_from(std::move(init_data));
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("background_attr"); GLShaderProgram* shader = wxGetApp().get_shader("background_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("background"); GLShaderProgram* shader = wxGetApp().get_shader("background");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
shader->set_uniform("top_color", use_error_color ? ERROR_BG_LIGHT_COLOR : DEFAULT_BG_LIGHT_COLOR); shader->set_uniform("top_color", use_error_color ? ERROR_BG_LIGHT_COLOR : DEFAULT_BG_LIGHT_COLOR);
@ -5487,18 +5482,18 @@ void GLCanvas3D::_render_background()
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
glsafe(::glMatrixMode(GL_MODELVIEW)); glsafe(::glMatrixMode(GL_MODELVIEW));
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLCanvas3D::_render_bed(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_axes) void GLCanvas3D::_render_bed(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_axes)
#else #else
void GLCanvas3D::_render_bed(bool bottom, bool show_axes) void GLCanvas3D::_render_bed(bool bottom, bool show_axes)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
float scale_factor = 1.0; float scale_factor = 1.0;
#if ENABLE_RETINA_GL #if ENABLE_RETINA_GL
@ -5512,29 +5507,29 @@ void GLCanvas3D::_render_bed(bool bottom, bool show_axes)
&& m_gizmos.get_current_type() != GLGizmosManager::Seam && m_gizmos.get_current_type() != GLGizmosManager::Seam
&& m_gizmos.get_current_type() != GLGizmosManager::MmuSegmentation); && m_gizmos.get_current_type() != GLGizmosManager::MmuSegmentation);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
m_bed.render(*this, view_matrix, projection_matrix, bottom, scale_factor, show_axes, show_texture); m_bed.render(*this, view_matrix, projection_matrix, bottom, scale_factor, show_axes, show_texture);
#else #else
m_bed.render(*this, bottom, scale_factor, show_axes, show_texture); m_bed.render(*this, bottom, scale_factor, show_axes, show_texture);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLCanvas3D::_render_bed_for_picking(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom) void GLCanvas3D::_render_bed_for_picking(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom)
#else #else
void GLCanvas3D::_render_bed_for_picking(bool bottom) void GLCanvas3D::_render_bed_for_picking(bool bottom)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
float scale_factor = 1.0; float scale_factor = 1.0;
#if ENABLE_RETINA_GL #if ENABLE_RETINA_GL
scale_factor = m_retina_helper->get_scale_factor(); scale_factor = m_retina_helper->get_scale_factor();
#endif // ENABLE_RETINA_GL #endif // ENABLE_RETINA_GL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
m_bed.render_for_picking(*this, view_matrix, projection_matrix, bottom, scale_factor); m_bed.render_for_picking(*this, view_matrix, projection_matrix, bottom, scale_factor);
#else #else
m_bed.render_for_picking(*this, bottom, scale_factor); m_bed.render_for_picking(*this, bottom, scale_factor);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type) void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
@ -5591,11 +5586,11 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
m_volumes.set_show_non_manifold_edges(!m_gizmos.is_hiding_instances() && m_gizmos.get_current_type() != GLGizmosManager::Simplify); m_volumes.set_show_non_manifold_edges(!m_gizmos.is_hiding_instances() && m_gizmos.get_current_type() != GLGizmosManager::Simplify);
#endif // ENABLE_SHOW_NON_MANIFOLD_EDGES #endif // ENABLE_SHOW_NON_MANIFOLD_EDGES
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_attr"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("gouraud"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
@ -5606,7 +5601,7 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
{ {
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)) { 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; int object_id = m_layers_editing.last_object_id;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
m_volumes.render(type, false, camera.get_view_matrix(), camera.get_projection_matrix(), [object_id](const GLVolume& volume) { m_volumes.render(type, false, camera.get_view_matrix(), camera.get_projection_matrix(), [object_id](const GLVolume& volume) {
// Which volume to paint without the layer height profile shader? // Which volume to paint without the layer height profile shader?
@ -5617,13 +5612,13 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
// Which volume to paint without the layer height profile shader? // Which volume to paint without the layer height profile shader?
return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id); return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id);
}); });
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// Let LayersEditing handle rendering of the active object using the layer height profile shader. // Let LayersEditing handle rendering of the active object using the layer height profile shader.
m_layers_editing.render_volumes(*this, m_volumes); m_layers_editing.render_volumes(*this, m_volumes);
} }
else { else {
// do not cull backfaces to show broken geometry, if any // do not cull backfaces to show broken geometry, if any
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
m_volumes.render(type, m_picking_enabled, camera.get_view_matrix(), camera.get_projection_matrix(), [this](const GLVolume& volume) { m_volumes.render(type, m_picking_enabled, camera.get_view_matrix(), camera.get_projection_matrix(), [this](const GLVolume& volume) {
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0); return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
@ -5632,7 +5627,7 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
m_volumes.render(type, m_picking_enabled, wxGetApp().plater()->get_camera().get_view_matrix(), [this](const GLVolume& volume) { m_volumes.render(type, 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); return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
}); });
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
// In case a painting gizmo is open, it should render the painted triangles // In case a painting gizmo is open, it should render the painted triangles
@ -5651,12 +5646,12 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
} }
case GLVolumeCollection::ERenderType::Transparent: case GLVolumeCollection::ERenderType::Transparent:
{ {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
m_volumes.render(type, false, camera.get_view_matrix(), camera.get_projection_matrix()); m_volumes.render(type, false, camera.get_view_matrix(), camera.get_projection_matrix());
#else #else
m_volumes.render(type, false, wxGetApp().plater()->get_camera().get_view_matrix()); m_volumes.render(type, false, wxGetApp().plater()->get_camera().get_view_matrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
break; break;
} }
} }
@ -5816,11 +5811,11 @@ void GLCanvas3D::_render_overlays()
void GLCanvas3D::_render_volumes_for_picking() const void GLCanvas3D::_render_volumes_for_picking() const
{ {
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
@ -5828,10 +5823,10 @@ void GLCanvas3D::_render_volumes_for_picking() const
// do not cull backfaces to show broken geometry, if any // do not cull backfaces to show broken geometry, if any
glsafe(::glDisable(GL_CULL_FACE)); glsafe(::glDisable(GL_CULL_FACE));
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d& view_matrix = wxGetApp().plater()->get_camera().get_view_matrix(); const Transform3d& view_matrix = wxGetApp().plater()->get_camera().get_view_matrix();
for (size_t type = 0; type < 2; ++ type) { for (size_t type = 0; type < 2; ++ type) {
@ -5848,11 +5843,11 @@ void GLCanvas3D::_render_volumes_for_picking() const
#else #else
glsafe(::glColor4fv(picking_decode(id).data())); glsafe(::glColor4fv(picking_decode(id).data()));
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_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() * volume.first->world_matrix()); shader->set_uniform("view_model_matrix", camera.get_view_matrix() * volume.first->world_matrix());
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
volume.first->render(); volume.first->render();
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
shader->stop_using(); shader->stop_using();
@ -5860,10 +5855,10 @@ void GLCanvas3D::_render_volumes_for_picking() const
} }
} }
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glDisableClientState(GL_NORMAL_ARRAY)); glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glEnable(GL_CULL_FACE)); glsafe(::glEnable(GL_CULL_FACE));
} }
@ -5898,20 +5893,20 @@ void GLCanvas3D::_render_main_toolbar()
return; return;
const Size cnv_size = get_canvas_size(); const Size cnv_size = get_canvas_size();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const float top = 0.5f * (float)cnv_size.get_height(); const float top = 0.5f * (float)cnv_size.get_height();
#else #else
const float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom(); const float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
const float top = 0.5f * (float)cnv_size.get_height() * inv_zoom; const float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar(); GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
const float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f; const float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width); const float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width);
#else #else
const float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width) * inv_zoom; const float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width) * inv_zoom;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_main_toolbar.set_position(top, left); m_main_toolbar.set_position(top, left);
m_main_toolbar.render(*this); m_main_toolbar.render(*this);
@ -5925,20 +5920,20 @@ void GLCanvas3D::_render_undoredo_toolbar()
return; return;
const Size cnv_size = get_canvas_size(); const Size cnv_size = get_canvas_size();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const float top = 0.5f * (float)cnv_size.get_height(); const float top = 0.5f * (float)cnv_size.get_height();
#else #else
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom(); float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
const float top = 0.5f * (float)cnv_size.get_height() * inv_zoom; const float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar(); GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
const float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f; const float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const float left = m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width); const float left = m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width);
#else #else
const float left = (m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width)) * inv_zoom; const float left = (m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width)) * inv_zoom;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_undoredo_toolbar.set_position(top, left); m_undoredo_toolbar.set_position(top, left);
m_undoredo_toolbar.render(*this); m_undoredo_toolbar.render(*this);
@ -5952,7 +5947,7 @@ void GLCanvas3D::_render_collapse_toolbar() const
const Size cnv_size = get_canvas_size(); const Size cnv_size = get_canvas_size();
const float band = m_layers_editing.is_enabled() ? (wxGetApp().imgui()->get_style_scaling() * LayersEditing::THICKNESS_BAR_WIDTH) : 0.0; const float band = m_layers_editing.is_enabled() ? (wxGetApp().imgui()->get_style_scaling() * LayersEditing::THICKNESS_BAR_WIDTH) : 0.0;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const float top = 0.5f * (float)cnv_size.get_height(); const float top = 0.5f * (float)cnv_size.get_height();
const float left = 0.5f * (float)cnv_size.get_width() - collapse_toolbar.get_width() - band; const float left = 0.5f * (float)cnv_size.get_width() - collapse_toolbar.get_width() - band;
#else #else
@ -5960,7 +5955,7 @@ void GLCanvas3D::_render_collapse_toolbar() const
const float top = 0.5f * (float)cnv_size.get_height() * inv_zoom; const float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
const float left = (0.5f * (float)cnv_size.get_width() - (float)collapse_toolbar.get_width() - band) * inv_zoom; const float left = (0.5f * (float)cnv_size.get_width() - (float)collapse_toolbar.get_width() - band) * inv_zoom;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
collapse_toolbar.set_position(top, left); collapse_toolbar.set_position(top, left);
collapse_toolbar.render(*this); collapse_toolbar.render(*this);
@ -5984,7 +5979,7 @@ void GLCanvas3D::_render_view_toolbar() const
#endif // ENABLE_RETINA_GL #endif // ENABLE_RETINA_GL
const Size cnv_size = get_canvas_size(); const Size cnv_size = get_canvas_size();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
// places the toolbar on the bottom-left corner of the 3d scene // places the toolbar on the bottom-left corner of the 3d scene
float top = -0.5f * (float)cnv_size.get_height() + view_toolbar.get_height(); float top = -0.5f * (float)cnv_size.get_height() + view_toolbar.get_height();
float left = -0.5f * (float)cnv_size.get_width(); float left = -0.5f * (float)cnv_size.get_width();
@ -5994,7 +5989,7 @@ void GLCanvas3D::_render_view_toolbar() const
// places the toolbar on the bottom-left corner of the 3d scene // places the toolbar on the bottom-left corner of the 3d scene
float top = (-0.5f * (float)cnv_size.get_height() + view_toolbar.get_height()) * inv_zoom; float top = (-0.5f * (float)cnv_size.get_height() + view_toolbar.get_height()) * inv_zoom;
float left = -0.5f * (float)cnv_size.get_width() * inv_zoom; float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
view_toolbar.set_position(top, left); view_toolbar.set_position(top, left);
view_toolbar.render(*this); view_toolbar.render(*this);
} }
@ -6043,18 +6038,18 @@ void GLCanvas3D::_render_camera_target()
} }
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
m_camera_target.axis[i].render(); m_camera_target.axis[i].render();
} }
@ -6232,16 +6227,16 @@ void GLCanvas3D::_render_sla_slices()
} }
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
for (const SLAPrintObject::Instance& inst : obj->instances()) { for (const SLAPrintObject::Instance& inst : obj->instances()) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Transform3d view_model_matrix = camera.get_view_matrix() * const Transform3d view_model_matrix = camera.get_view_matrix() *
Geometry::assemble_transform(Vec3d(unscale<double>(inst.shift.x()), unscale<double>(inst.shift.y()), 0.0), Geometry::assemble_transform(Vec3d(unscale<double>(inst.shift.x()), unscale<double>(inst.shift.y()), 0.0),
@ -6257,16 +6252,16 @@ void GLCanvas3D::_render_sla_slices()
if (obj->is_left_handed()) if (obj->is_left_handed())
// The polygons are mirrored by X. // The polygons are mirrored by X.
glsafe(::glScalef(-1.0f, 1.0f, 1.0f)); glsafe(::glScalef(-1.0f, 1.0f, 1.0f));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
bottom_obj_triangles.render(); bottom_obj_triangles.render();
top_obj_triangles.render(); top_obj_triangles.render();
bottom_sup_triangles.render(); bottom_sup_triangles.render();
top_sup_triangles.render(); top_sup_triangles.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
shader->stop_using(); shader->stop_using();

View File

@ -245,15 +245,15 @@ class GLCanvas3D
GLModel baseline; GLModel baseline;
GLModel profile; GLModel profile;
GLModel background; GLModel background;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
float old_canvas_width{ 0.0f }; float old_canvas_width{ 0.0f };
#else #else
Rect old_bar_rect; Rect old_bar_rect;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
std::vector<double> old_layer_height_profile; std::vector<double> old_layer_height_profile;
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
bool dirty{ false }; bool dirty{ false };
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
}; };
Profile m_profile; Profile m_profile;
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
@ -283,9 +283,9 @@ class GLCanvas3D
static float get_cursor_z_relative(const GLCanvas3D& canvas); static float get_cursor_z_relative(const GLCanvas3D& canvas);
static bool bar_rect_contains(const GLCanvas3D& canvas, float x, float y); static bool bar_rect_contains(const GLCanvas3D& canvas, float x, float y);
static Rect get_bar_rect_screen(const GLCanvas3D& canvas); static Rect get_bar_rect_screen(const GLCanvas3D& canvas);
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
static Rect get_bar_rect_viewport(const GLCanvas3D& canvas); static Rect get_bar_rect_viewport(const GLCanvas3D& canvas);
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
static float get_overlay_window_width() { return LayersEditing::s_overlay_window_width; } static float get_overlay_window_width() { return LayersEditing::s_overlay_window_width; }
float object_max_z() const { return m_object_max_z; } float object_max_z() const { return m_object_max_z; }
@ -295,13 +295,13 @@ class GLCanvas3D
private: private:
bool is_initialized() const; bool is_initialized() const;
void generate_layer_height_texture(); void generate_layer_height_texture();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void render_active_object_annotations(const GLCanvas3D& canvas); void render_active_object_annotations(const GLCanvas3D& canvas);
void render_profile(const GLCanvas3D& canvas); void render_profile(const GLCanvas3D& canvas);
#else #else
void render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect); void render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect);
void render_profile(const Rect& bar_rect); void render_profile(const Rect& bar_rect);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void update_slicing_parameters(); void update_slicing_parameters();
static float thickness_bar_width(const GLCanvas3D &canvas); static float thickness_bar_width(const GLCanvas3D &canvas);
@ -953,13 +953,13 @@ private:
void _picking_pass(); void _picking_pass();
void _rectangular_selection_picking_pass(); void _rectangular_selection_picking_pass();
void _render_background(); void _render_background();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void _render_bed(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_axes); void _render_bed(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_axes);
void _render_bed_for_picking(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom); void _render_bed_for_picking(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom);
#else #else
void _render_bed(bool bottom, bool show_axes); void _render_bed(bool bottom, bool show_axes);
void _render_bed_for_picking(bool bottom); void _render_bed_for_picking(bool bottom);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void _render_objects(GLVolumeCollection::ERenderType type); void _render_objects(GLVolumeCollection::ERenderType type);
void _render_gcode(); void _render_gcode();
#if ENABLE_SHOW_TOOLPATHS_COG #if ENABLE_SHOW_TOOLPATHS_COG

View File

@ -985,14 +985,14 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_render_data.vbo_id)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_render_data.vbo_id));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
int position_id = -1; int position_id = -1;
int normal_id = -1; int normal_id = -1;
int tex_coord_id = -1; int tex_coord_id = -1;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (position) { if (position) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
position_id = shader->get_attrib_location("v_position"); position_id = shader->get_attrib_location("v_position");
if (position_id != -1) { if (position_id != -1) {
glsafe(::glVertexAttribPointer(position_id, Geometry::position_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (GLvoid*)Geometry::position_offset_bytes(data.format))); glsafe(::glVertexAttribPointer(position_id, Geometry::position_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (GLvoid*)Geometry::position_offset_bytes(data.format)));
@ -1001,10 +1001,10 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
#else #else
glsafe(::glVertexPointer(Geometry::position_stride_floats(data.format), GL_FLOAT, vertex_stride_bytes, (const void*)Geometry::position_offset_bytes(data.format))); glsafe(::glVertexPointer(Geometry::position_stride_floats(data.format), GL_FLOAT, vertex_stride_bytes, (const void*)Geometry::position_offset_bytes(data.format)));
glsafe(::glEnableClientState(GL_VERTEX_ARRAY)); glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
if (normal) { if (normal) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
normal_id = shader->get_attrib_location("v_normal"); normal_id = shader->get_attrib_location("v_normal");
if (normal_id != -1) { if (normal_id != -1) {
glsafe(::glVertexAttribPointer(normal_id, Geometry::normal_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (GLvoid*)Geometry::normal_offset_bytes(data.format))); glsafe(::glVertexAttribPointer(normal_id, Geometry::normal_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (GLvoid*)Geometry::normal_offset_bytes(data.format)));
@ -1013,10 +1013,10 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
#else #else
glsafe(::glNormalPointer(GL_FLOAT, vertex_stride_bytes, (const void*)Geometry::normal_offset_bytes(data.format))); glsafe(::glNormalPointer(GL_FLOAT, vertex_stride_bytes, (const void*)Geometry::normal_offset_bytes(data.format)));
glsafe(::glEnableClientState(GL_NORMAL_ARRAY)); glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
if (tex_coord) { if (tex_coord) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
tex_coord_id = shader->get_attrib_location("v_tex_coord"); tex_coord_id = shader->get_attrib_location("v_tex_coord");
if (tex_coord_id != -1) { if (tex_coord_id != -1) {
glsafe(::glVertexAttribPointer(tex_coord_id, Geometry::tex_coord_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (GLvoid*)Geometry::tex_coord_offset_bytes(data.format))); glsafe(::glVertexAttribPointer(tex_coord_id, Geometry::tex_coord_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (GLvoid*)Geometry::tex_coord_offset_bytes(data.format)));
@ -1025,7 +1025,7 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
#else #else
glsafe(::glTexCoordPointer(Geometry::tex_coord_stride_floats(data.format), GL_FLOAT, vertex_stride_bytes, (const void*)Geometry::tex_coord_offset_bytes(data.format))); glsafe(::glTexCoordPointer(Geometry::tex_coord_stride_floats(data.format), GL_FLOAT, vertex_stride_bytes, (const void*)Geometry::tex_coord_offset_bytes(data.format)));
glsafe(::glEnableClientState(GL_TEXTURE_COORD_ARRAY)); glsafe(::glEnableClientState(GL_TEXTURE_COORD_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
shader->set_uniform("uniform_color", data.color); shader->set_uniform("uniform_color", data.color);
@ -1034,7 +1034,7 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
glsafe(::glDrawElements(mode, range.second - range.first, index_type, (const void*)(range.first * Geometry::index_stride_bytes(data.format)))); glsafe(::glDrawElements(mode, range.second - range.first, index_type, (const void*)(range.first * Geometry::index_stride_bytes(data.format))));
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (tex_coord_id != -1) if (tex_coord_id != -1)
glsafe(::glDisableVertexAttribArray(tex_coord_id)); glsafe(::glDisableVertexAttribArray(tex_coord_id));
if (normal_id != -1) if (normal_id != -1)
@ -1048,7 +1048,7 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
glsafe(::glDisableClientState(GL_NORMAL_ARRAY)); glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
if (position) if (position)
glsafe(::glDisableClientState(GL_VERTEX_ARRAY)); glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
} }
@ -1065,11 +1065,11 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance
GLShaderProgram* shader = wxGetApp().get_current_shader(); GLShaderProgram* shader = wxGetApp().get_current_shader();
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr || !boost::algorithm::iends_with(shader->get_name(), "_instanced_attr")) if (shader == nullptr || !boost::algorithm::iends_with(shader->get_name(), "_instanced_attr"))
#else #else
if (shader == nullptr || !boost::algorithm::iends_with(shader->get_name(), "_instanced")) if (shader == nullptr || !boost::algorithm::iends_with(shader->get_name(), "_instanced"))
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
return; return;
// vertex attributes // vertex attributes

View File

@ -74,32 +74,28 @@ namespace GUI {
if (!is_dragging()) if (!is_dragging())
return; return;
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera();
const float inv_zoom = (float)camera.get_inv_zoom();
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
const Size cnv_size = canvas.get_canvas_size(); const Size cnv_size = canvas.get_canvas_size();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const float cnv_width = (float)cnv_size.get_width(); const float cnv_width = (float)cnv_size.get_width();
const float cnv_height = (float)cnv_size.get_height(); const float cnv_height = (float)cnv_size.get_height();
if (cnv_width == 0.0f || cnv_height == 0.0f) if (cnv_width == 0.0f || cnv_height == 0.0f)
return; return;
const float cnv_inv_width = 1.0f / cnv_width;
const float cnv_inv_height = 1.0f / cnv_height;
const float left = 2.0f * (get_left() * cnv_inv_width - 0.5f);
const float right = 2.0f * (get_right() * cnv_inv_width - 0.5f);
const float top = -2.0f * (get_top() * cnv_inv_height - 0.5f);
const float bottom = -2.0f * (get_bottom() * cnv_inv_height - 0.5f);
#else #else
const Camera& camera = wxGetApp().plater()->get_camera();
const float inv_zoom = (float)camera.get_inv_zoom();
const float cnv_half_width = 0.5f * (float)cnv_size.get_width(); const float cnv_half_width = 0.5f * (float)cnv_size.get_width();
const float cnv_half_height = 0.5f * (float)cnv_size.get_height(); const float cnv_half_height = 0.5f * (float)cnv_size.get_height();
if (cnv_half_width == 0.0f || cnv_half_height == 0.0f) if (cnv_half_width == 0.0f || cnv_half_height == 0.0f)
return; return;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
const float cnv_inv_width = 1.0f / cnv_width;
const float cnv_inv_height = 1.0f / cnv_height;
const float left = 2.0f * (get_left() * cnv_inv_width - 0.5f);
const float right = 2.0f * (get_right() * cnv_inv_width - 0.5f);
const float top = -2.0f * (get_top() * cnv_inv_height - 0.5f);
const float bottom = -2.0f * (get_bottom() * cnv_inv_height - 0.5f);
#else
const Vec2d start(m_start_corner.x() - cnv_half_width, cnv_half_height - m_start_corner.y()); const Vec2d start(m_start_corner.x() - cnv_half_width, cnv_half_height - m_start_corner.y());
const Vec2d end(m_end_corner.x() - cnv_half_width, cnv_half_height - m_end_corner.y()); const Vec2d end(m_end_corner.x() - cnv_half_width, cnv_half_height - m_end_corner.y());
@ -107,7 +103,7 @@ namespace GUI {
const float top = (float)std::max(start.y(), end.y()) * inv_zoom; const float top = (float)std::max(start.y(), end.y()) * inv_zoom;
const float right = (float)std::max(start.x(), end.x()) * inv_zoom; const float right = (float)std::max(start.x(), end.x()) * inv_zoom;
const float bottom = (float)std::min(start.y(), end.y()) * inv_zoom; const float bottom = (float)std::min(start.y(), end.y()) * inv_zoom;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glLineWidth(1.5f)); glsafe(::glLineWidth(1.5f));
#if !ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_LEGACY_OPENGL_REMOVAL
@ -120,7 +116,7 @@ namespace GUI {
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glLoadIdentity()); glsafe(::glLoadIdentity());
// ensure that the rectangle is renderered inside the frustrum // ensure that the rectangle is renderered inside the frustrum
@ -128,18 +124,18 @@ namespace GUI {
// ensure that the overlay fits the frustrum near z plane // ensure that the overlay fits the frustrum near z plane
const double gui_scale = camera.get_gui_scale(); const double gui_scale = camera.get_gui_scale();
glsafe(::glScaled(gui_scale, gui_scale, 1.0)); glsafe(::glScaled(gui_scale, gui_scale, 1.0));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPushAttrib(GL_ENABLE_BIT)); glsafe(::glPushAttrib(GL_ENABLE_BIT));
glsafe(::glLineStipple(4, 0xAAAA)); glsafe(::glLineStipple(4, 0xAAAA));
glsafe(::glEnable(GL_LINE_STIPPLE)); glsafe(::glEnable(GL_LINE_STIPPLE));
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
@ -168,10 +164,10 @@ namespace GUI {
m_rectangle.init_from(std::move(init_data)); m_rectangle.init_from(std::move(init_data));
} }
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_rectangle.set_color(ColorRGBA((m_state == Select) ? 0.3f : 1.0f, (m_state == Select) ? 1.0f : 0.3f, 0.3f, 1.0f)); m_rectangle.set_color(ColorRGBA((m_state == Select) ? 0.3f : 1.0f, (m_state == Select) ? 1.0f : 0.3f, 0.3f, 1.0f));
m_rectangle.render(); m_rectangle.render();
@ -188,9 +184,9 @@ namespace GUI {
glsafe(::glPopAttrib()); glsafe(::glPopAttrib());
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
} // namespace GUI } // namespace GUI

View File

@ -296,12 +296,12 @@ void GLShaderProgram::set_uniform(int id, const Matrix3f& value) const
glsafe(::glUniformMatrix3fv(id, 1, GL_FALSE, static_cast<const GLfloat*>(value.data()))); glsafe(::glUniformMatrix3fv(id, 1, GL_FALSE, static_cast<const GLfloat*>(value.data())));
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLShaderProgram::set_uniform(int id, const Matrix3d& value) const void GLShaderProgram::set_uniform(int id, const Matrix3d& value) const
{ {
set_uniform(id, (Matrix3f)value.cast<float>()); set_uniform(id, (Matrix3f)value.cast<float>());
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void GLShaderProgram::set_uniform(int id, const Vec3f& value) const void GLShaderProgram::set_uniform(int id, const Vec3f& value) const
{ {

View File

@ -61,9 +61,9 @@ public:
void set_uniform(const char* name, const Transform3f& value) const { set_uniform(get_uniform_location(name), value); } void set_uniform(const char* name, const Transform3f& value) const { set_uniform(get_uniform_location(name), value); }
void set_uniform(const char* name, const Transform3d& value) const { set_uniform(get_uniform_location(name), value); } void set_uniform(const char* name, const Transform3d& value) const { set_uniform(get_uniform_location(name), value); }
void set_uniform(const char* name, const Matrix3f& value) const { set_uniform(get_uniform_location(name), value); } void set_uniform(const char* name, const Matrix3f& value) const { set_uniform(get_uniform_location(name), value); }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void set_uniform(const char* name, const Matrix3d& value) const { set_uniform(get_uniform_location(name), value); } void set_uniform(const char* name, const Matrix3d& value) const { set_uniform(get_uniform_location(name), value); }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void set_uniform(const char* name, const Vec3f& value) const { set_uniform(get_uniform_location(name), value); } void set_uniform(const char* name, const Vec3f& value) const { set_uniform(get_uniform_location(name), value); }
void set_uniform(const char* name, const Vec3d& value) const { set_uniform(get_uniform_location(name), value); } void set_uniform(const char* name, const Vec3d& value) const { set_uniform(get_uniform_location(name), value); }
void set_uniform(const char* name, const ColorRGB& value) const { set_uniform(get_uniform_location(name), value); } void set_uniform(const char* name, const ColorRGB& value) const { set_uniform(get_uniform_location(name), value); }
@ -83,9 +83,9 @@ public:
void set_uniform(int id, const Transform3f& value) const; void set_uniform(int id, const Transform3f& value) const;
void set_uniform(int id, const Transform3d& value) const; void set_uniform(int id, const Transform3d& value) const;
void set_uniform(int id, const Matrix3f& value) const; void set_uniform(int id, const Matrix3f& value) const;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void set_uniform(int id, const Matrix3d& value) const; void set_uniform(int id, const Matrix3d& value) const;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void set_uniform(int id, const Vec3f& value) const; void set_uniform(int id, const Vec3f& value) const;
void set_uniform(int id, const Vec3d& value) const; void set_uniform(int id, const Vec3d& value) const;
void set_uniform(int id, const ColorRGB& value) const; void set_uniform(int id, const ColorRGB& value) const;

View File

@ -34,86 +34,80 @@ std::pair<bool, std::string> GLShadersManager::init()
bool valid = true; bool valid = true;
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GL_SHADERS_ATTRIBUTES
// 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
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
valid &= append_shader("flat_attr", { "flat_attr.vs", "flat.fs" }); valid &= append_shader("flat_attr", { "flat_attr.vs", "flat.fs" });
#else
valid &= append_shader("flat", { "flat.vs", "flat.fs" });
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
// basic shader for textures, used to render textures // basic shader for textures, used to render textures
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
valid &= append_shader("flat_texture_attr", { "flat_texture_attr.vs", "flat_texture.fs" }); valid &= append_shader("flat_texture_attr", { "flat_texture_attr.vs", "flat_texture.fs" });
#else
valid &= append_shader("flat_texture", { "flat_texture.vs", "flat_texture.fs" });
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
// used to render 3D scene background // used to render 3D scene background
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
valid &= append_shader("background_attr", { "background_attr.vs", "background.fs" }); valid &= append_shader("background_attr", { "background_attr.vs", "background.fs" });
#else #else
// basic shader, used to render all what was previously rendered using the immediate mode
valid &= append_shader("flat", { "flat.vs", "flat.fs" });
// basic shader for textures, used to render textures
valid &= append_shader("flat_texture", { "flat_texture.vs", "flat_texture.fs" });
// used to render 3D scene background
valid &= append_shader("background", { "background.vs", "background.fs" }); valid &= append_shader("background", { "background.vs", "background.fs" });
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_SHOW_TOOLPATHS_COG #if ENABLE_SHOW_TOOLPATHS_COG
// used to render toolpaths center of gravity // used to render toolpaths center of gravity
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
valid &= append_shader("toolpaths_cog_attr", { "toolpaths_cog_attr.vs", "toolpaths_cog.fs" }); valid &= append_shader("toolpaths_cog_attr", { "toolpaths_cog_attr.vs", "toolpaths_cog.fs" });
#else #else
valid &= append_shader("toolpaths_cog", { "toolpaths_cog.vs", "toolpaths_cog.fs" }); valid &= append_shader("toolpaths_cog", { "toolpaths_cog.vs", "toolpaths_cog.fs" });
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#endif // ENABLE_SHOW_TOOLPATHS_COG #endif // ENABLE_SHOW_TOOLPATHS_COG
#if ENABLE_GL_SHADERS_ATTRIBUTES
// used to render bed axes and model, selection hints, gcode sequential view marker model, preview shells, options in gcode preview // used to render bed axes and model, selection hints, gcode sequential view marker model, preview shells, options in gcode preview
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
valid &= append_shader("gouraud_light_attr", { "gouraud_light_attr.vs", "gouraud_light.fs" }); valid &= append_shader("gouraud_light_attr", { "gouraud_light_attr.vs", "gouraud_light.fs" });
#else
valid &= append_shader("gouraud_light", { "gouraud_light.vs", "gouraud_light.fs" });
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
// used to render printbed // used to render printbed
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
valid &= append_shader("printbed_attr", { "printbed_attr.vs", "printbed.fs" }); valid &= append_shader("printbed_attr", { "printbed_attr.vs", "printbed.fs" });
#else #else
// used to render bed axes and model, selection hints, gcode sequential view marker model, preview shells, options in gcode preview
valid &= append_shader("gouraud_light", { "gouraud_light.vs", "gouraud_light.fs" });
// used to render printbed
valid &= append_shader("printbed", { "printbed.vs", "printbed.fs" }); valid &= append_shader("printbed", { "printbed.vs", "printbed.fs" });
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// used to render options in gcode preview // used to render options in gcode preview
if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 3)) { if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 3)) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
valid &= append_shader("gouraud_light_instanced_attr", { "gouraud_light_instanced_attr.vs", "gouraud_light_instanced.fs" }); valid &= append_shader("gouraud_light_instanced_attr", { "gouraud_light_instanced_attr.vs", "gouraud_light_instanced.fs" });
#else #else
valid &= append_shader("gouraud_light_instanced", { "gouraud_light_instanced.vs", "gouraud_light_instanced.fs" }); valid &= append_shader("gouraud_light_instanced", { "gouraud_light_instanced.vs", "gouraud_light_instanced.fs" });
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
// used to render extrusion and travel paths as lines in gcode preview
valid &= append_shader("toolpaths_lines", { "toolpaths_lines.vs", "toolpaths_lines.fs" });
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
// used to render objects in 3d editor // used to render objects in 3d editor
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
valid &= append_shader("gouraud_attr", { "gouraud_attr.vs", "gouraud.fs" } valid &= append_shader("gouraud_attr", { "gouraud_attr.vs", "gouraud.fs" }
#else #else
// used to render extrusion and travel paths as lines in gcode preview
valid &= append_shader("toolpaths_lines", { "toolpaths_lines.vs", "toolpaths_lines.fs" });
// used to render objects in 3d editor
valid &= append_shader("gouraud", { "gouraud.vs", "gouraud.fs" } valid &= append_shader("gouraud", { "gouraud.vs", "gouraud.fs" }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_ENVIRONMENT_MAP #if ENABLE_ENVIRONMENT_MAP
, { "ENABLE_ENVIRONMENT_MAP"sv } , { "ENABLE_ENVIRONMENT_MAP"sv }
#endif // ENABLE_ENVIRONMENT_MAP #endif // ENABLE_ENVIRONMENT_MAP
); );
#if ENABLE_GL_SHADERS_ATTRIBUTES
// used to render variable layers heights in 3d editor // used to render variable layers heights in 3d editor
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
valid &= append_shader("variable_layer_height_attr", { "variable_layer_height_attr.vs", "variable_layer_height.fs" }); valid &= append_shader("variable_layer_height_attr", { "variable_layer_height_attr.vs", "variable_layer_height.fs" });
#else
valid &= append_shader("variable_layer_height", { "variable_layer_height.vs", "variable_layer_height.fs" });
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
// used to render highlight contour around selected triangles inside the multi-material gizmo // used to render highlight contour around selected triangles inside the multi-material gizmo
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
valid &= append_shader("mm_contour_attr", { "mm_contour_attr.vs", "mm_contour_attr.fs" }); valid &= append_shader("mm_contour_attr", { "mm_contour_attr.vs", "mm_contour_attr.fs" });
#else #else
// used to render variable layers heights in 3d editor
valid &= append_shader("variable_layer_height", { "variable_layer_height.vs", "variable_layer_height.fs" });
// used to render highlight contour around selected triangles inside the multi-material gizmo
valid &= append_shader("mm_contour", { "mm_contour.vs", "mm_contour.fs" }); valid &= append_shader("mm_contour", { "mm_contour.vs", "mm_contour.fs" });
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// Used to render painted triangles inside the multi-material gizmo. Triangle normals are computed inside fragment shader. // Used to render painted triangles inside the multi-material gizmo. Triangle normals are computed inside fragment shader.
// For Apple's on Arm CPU computed triangle normals inside fragment shader using dFdx and dFdy has the opposite direction. // For Apple's on Arm CPU computed triangle normals inside fragment shader using dFdx and dFdy has the opposite direction.
// Because of this, objects had darker colors inside the multi-material gizmo. // Because of this, objects had darker colors inside the multi-material gizmo.
// Based on https://stackoverflow.com/a/66206648, the similar behavior was also spotted on some other devices with Arm CPU. // Based on https://stackoverflow.com/a/66206648, the similar behavior was also spotted on some other devices with Arm CPU.
// Since macOS 12 (Monterey), this issue with the opposite direction on Apple's Arm CPU seems to be fixed, and computed // Since macOS 12 (Monterey), this issue with the opposite direction on Apple's Arm CPU seems to be fixed, and computed
// triangle normals inside fragment shader have the right direction. // triangle normals inside fragment shader have the right direction.
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (platform_flavor() == PlatformFlavor::OSXOnArm && wxPlatformInfo::Get().GetOSMajorVersion() < 12) if (platform_flavor() == PlatformFlavor::OSXOnArm && wxPlatformInfo::Get().GetOSMajorVersion() < 12)
valid &= append_shader("mm_gouraud_attr", { "mm_gouraud_attr.vs", "mm_gouraud_attr.fs" }, { "FLIP_TRIANGLE_NORMALS"sv }); valid &= append_shader("mm_gouraud_attr", { "mm_gouraud_attr.vs", "mm_gouraud_attr.fs" }, { "FLIP_TRIANGLE_NORMALS"sv });
else else
@ -123,7 +117,7 @@ std::pair<bool, std::string> GLShadersManager::init()
valid &= append_shader("mm_gouraud", {"mm_gouraud.vs", "mm_gouraud.fs"}, {"FLIP_TRIANGLE_NORMALS"sv}); valid &= append_shader("mm_gouraud", {"mm_gouraud.vs", "mm_gouraud.fs"}, {"FLIP_TRIANGLE_NORMALS"sv});
else else
valid &= append_shader("mm_gouraud", {"mm_gouraud.vs", "mm_gouraud.fs"}); valid &= append_shader("mm_gouraud", {"mm_gouraud.vs", "mm_gouraud.fs"});
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
return { valid, error }; return { valid, error };
} }

View File

@ -358,17 +358,17 @@ void GLTexture::render_sub_texture(unsigned int tex_id, float left, float right,
GLModel model; GLModel model;
model.init_from(std::move(init_data)); model.init_from(std::move(init_data));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_texture_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_texture_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat_texture"); GLShaderProgram* shader = wxGetApp().get_shader("flat_texture");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
model.render(); model.render();
shader->stop_using(); shader->stop_using();
} }

View File

@ -85,11 +85,11 @@ bool GLToolbarItem::update_enabled_state()
return ret; return ret;
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLToolbarItem::render(const GLCanvas3D& parent, unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const void GLToolbarItem::render(const GLCanvas3D& parent, unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const
#else #else
void GLToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const void GLToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
auto uvs = [this](unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) -> GLTexture::Quad_UVs { auto uvs = [this](unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) -> GLTexture::Quad_UVs {
assert(tex_width != 0 && tex_height != 0); assert(tex_width != 0 && tex_height != 0);
@ -118,7 +118,7 @@ void GLToolbarItem::render(unsigned int tex_id, float left, float right, float b
GLTexture::render_sub_texture(tex_id, left, right, bottom, top, uvs(tex_width, tex_height, icon_size)); GLTexture::render_sub_texture(tex_id, left, right, bottom, top, uvs(tex_width, tex_height, icon_size));
if (is_pressed()) { if (is_pressed()) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Size cnv_size = parent.get_canvas_size(); const Size cnv_size = parent.get_canvas_size();
const float cnv_w = (float)cnv_size.get_width(); const float cnv_w = (float)cnv_size.get_width();
const float cnv_h = (float)cnv_size.get_height(); const float cnv_h = (float)cnv_size.get_height();
@ -136,7 +136,7 @@ void GLToolbarItem::render(unsigned int tex_id, float left, float right, float b
m_data.left.render_callback(left, right, bottom, top); m_data.left.render_callback(left, right, bottom, top);
else if (m_last_action_type == Right && m_data.right.can_render()) else if (m_last_action_type == Right && m_data.right.can_render())
m_data.right.render_callback(left, right, bottom, top); m_data.right.render_callback(left, right, bottom, top);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
} }
@ -202,7 +202,7 @@ bool GLToolbar::init(const BackgroundTexture::Metadata& background_texture)
return res; return res;
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
bool GLToolbar::init_arrow(const std::string& filename) bool GLToolbar::init_arrow(const std::string& filename)
{ {
if (m_arrow_texture.get_id() != 0) if (m_arrow_texture.get_id() != 0)
@ -220,15 +220,15 @@ bool GLToolbar::init_arrow(const BackgroundTexture::Metadata& arrow_texture)
std::string path = resources_dir() + "/icons/"; std::string path = resources_dir() + "/icons/";
bool res = false; bool res = false;
if (!arrow_texture.filename.empty()) { if (!arrow_texture.filename.empty())
res = m_arrow_texture.texture.load_from_svg_file(path + arrow_texture.filename, false, false, false, 1000); res = m_arrow_texture.texture.load_from_svg_file(path + arrow_texture.filename, false, false, false, 1000);
}
if (res) if (res)
m_arrow_texture.metadata = arrow_texture; m_arrow_texture.metadata = arrow_texture;
return res; return res;
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
GLToolbar::Layout::EType GLToolbar::get_layout_type() const GLToolbar::Layout::EType GLToolbar::get_layout_type() const
{ {
@ -693,7 +693,7 @@ void GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent)
} }
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent) void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent)
{ {
const Size cnv_size = parent.get_canvas_size(); const Size cnv_size = parent.get_canvas_size();
@ -1108,7 +1108,7 @@ void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D&
} }
} }
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
GLToolbarItem* GLToolbar::get_item(const std::string& item_name) GLToolbarItem* GLToolbar::get_item(const std::string& item_name)
{ {
@ -1135,7 +1135,7 @@ int GLToolbar::contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent)
} }
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const
{ {
const Size cnv_size = parent.get_canvas_size(); const Size cnv_size = parent.get_canvas_size();
@ -1428,9 +1428,9 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D&
return -1; return -1;
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLToolbar::render_background(float left, float top, float right, float bottom, float border_w, float border_h) const void GLToolbar::render_background(float left, float top, float right, float bottom, float border_w, float border_h) const
{ {
const unsigned int tex_id = m_background_texture.texture.get_id(); const unsigned int tex_id = m_background_texture.texture.get_id();
@ -1584,9 +1584,9 @@ void GLToolbar::render_background(float left, float top, float right, float bott
GLTexture::render_sub_texture(tex_id, internal_right, right, bottom, internal_bottom, { { internal_right_uv, bottom_uv }, { right_uv, bottom_uv }, { right_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv } }); GLTexture::render_sub_texture(tex_id, internal_right, right, bottom, internal_bottom, { { internal_right_uv, bottom_uv }, { right_uv, bottom_uv }, { right_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv } });
} }
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLToolbar::render_arrow(const GLCanvas3D& parent, GLToolbarItem* highlighted_item) void GLToolbar::render_arrow(const GLCanvas3D& parent, GLToolbarItem* highlighted_item)
{ {
// arrow texture not initialized // arrow texture not initialized
@ -1721,9 +1721,9 @@ void GLToolbar::render_arrow(const GLCanvas3D& parent, GLToolbarItem* highlighte
GLTexture::render_sub_texture(tex_id, internal_left, internal_right, internal_bottom, internal_top, { { internal_left_uv, internal_top_uv }, { internal_right_uv, internal_top_uv }, { internal_right_uv, internal_bottom_uv }, { internal_left_uv, internal_bottom_uv } }); GLTexture::render_sub_texture(tex_id, internal_left, internal_right, internal_bottom, internal_top, { { internal_left_uv, internal_top_uv }, { internal_right_uv, internal_top_uv }, { internal_right_uv, internal_bottom_uv }, { internal_left_uv, internal_bottom_uv } });
} }
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLToolbar::render_horizontal(const GLCanvas3D& parent) void GLToolbar::render_horizontal(const GLCanvas3D& parent)
{ {
const Size cnv_size = parent.get_canvas_size(); const Size cnv_size = parent.get_canvas_size();
@ -1773,11 +1773,7 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent)
if (item->is_separator()) if (item->is_separator())
left += separator_stride; left += separator_stride;
else { else {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
item->render(parent, tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale)); item->render(parent, tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
#else
item->render(tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
left += icon_stride; left += icon_stride;
} }
} }
@ -1832,11 +1828,7 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent)
if (item->is_separator()) if (item->is_separator())
top -= separator_stride; top -= separator_stride;
else { else {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
item->render(parent, tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale)); item->render(parent, tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
#else
item->render(tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
top -= icon_stride; top -= icon_stride;
} }
} }
@ -1935,7 +1927,7 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent)
} }
} }
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
bool GLToolbar::generate_icons_texture() bool GLToolbar::generate_icons_texture()
{ {

View File

@ -153,11 +153,11 @@ public:
// returns true if the state changes // returns true if the state changes
bool update_enabled_state(); bool update_enabled_state();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void render(const GLCanvas3D& parent, unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const; void render(const GLCanvas3D& parent, unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const;
#else #else
void render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const; void render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
private: private:
void set_visible(bool visible) { m_data.visible = visible; } void set_visible(bool visible) { m_data.visible = visible; }
@ -251,11 +251,11 @@ private:
GLTexture m_icons_texture; GLTexture m_icons_texture;
bool m_icons_texture_dirty; bool m_icons_texture_dirty;
BackgroundTexture m_background_texture; BackgroundTexture m_background_texture;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLTexture m_arrow_texture; GLTexture m_arrow_texture;
#else #else
BackgroundTexture m_arrow_texture; BackgroundTexture m_arrow_texture;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
Layout m_layout; Layout m_layout;
ItemsList m_items; ItemsList m_items;
@ -282,11 +282,11 @@ public:
bool init(const BackgroundTexture::Metadata& background_texture); bool init(const BackgroundTexture::Metadata& background_texture);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
bool init_arrow(const std::string& filename); bool init_arrow(const std::string& filename);
#else #else
bool init_arrow(const BackgroundTexture::Metadata& arrow_texture); bool init_arrow(const BackgroundTexture::Metadata& arrow_texture);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
Layout::EType get_layout_type() const; Layout::EType get_layout_type() const;
void set_layout_type(Layout::EType type); void set_layout_type(Layout::EType type);
@ -357,11 +357,11 @@ private:
int contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const; int contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const;
int contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& parent) const; int contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& parent) const;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void render_background(float left, float top, float right, float bottom, float border_w, float border_h) const; void render_background(float left, float top, float right, float bottom, float border_w, float border_h) const;
#else #else
void render_background(float left, float top, float right, float bottom, float border) const; void render_background(float left, float top, float right, float bottom, float border) const;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void render_horizontal(const GLCanvas3D& parent); void render_horizontal(const GLCanvas3D& parent);
void render_vertical(const GLCanvas3D& parent); void render_vertical(const GLCanvas3D& parent);

View File

@ -5,9 +5,9 @@
#include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/GUI_ObjectManipulation.hpp" #include "slic3r/GUI/GUI_ObjectManipulation.hpp"
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
#include "slic3r/GUI/Plater.hpp" #include "slic3r/GUI/Plater.hpp"
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// TODO: Display tooltips quicker on Linux // TODO: Display tooltips quicker on Linux
@ -35,11 +35,11 @@ float GLGizmoBase::Grabber::get_dragging_half_size(float size) const
void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, bool picking) void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, bool picking)
{ {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_current_shader(); GLShaderProgram* shader = wxGetApp().get_current_shader();
if (shader == nullptr) if (shader == nullptr)
return; return;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (!m_cube.is_initialized()) { if (!m_cube.is_initialized()) {
// This cannot be done in constructor, OpenGL is not yet // This cannot be done in constructor, OpenGL is not yet
@ -61,7 +61,7 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo
m_cube.set_color(-1, render_color); m_cube.set_color(-1, render_color);
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Transform3d view_model_matrix = camera.get_view_matrix() * matrix * Geometry::assemble_transform(center, angles, fullsize * Vec3d::Ones()); const Transform3d view_model_matrix = camera.get_view_matrix() * matrix * Geometry::assemble_transform(center, angles, fullsize * Vec3d::Ones());
const Transform3d& projection_matrix = camera.get_projection_matrix(); const Transform3d& projection_matrix = camera.get_projection_matrix();
@ -76,11 +76,11 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo
glsafe(::glRotated(Geometry::rad2deg(angles.y()), 0.0, 1.0, 0.0)); glsafe(::glRotated(Geometry::rad2deg(angles.y()), 0.0, 1.0, 0.0));
glsafe(::glRotated(Geometry::rad2deg(angles.x()), 1.0, 0.0, 0.0)); glsafe(::glRotated(Geometry::rad2deg(angles.x()), 1.0, 0.0, 0.0));
glsafe(::glScaled(fullsize, fullsize, fullsize)); glsafe(::glScaled(fullsize, fullsize, fullsize));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_cube.render(); m_cube.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
@ -134,11 +134,11 @@ void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const
void GLGizmoBase::render_grabbers(float size) const void GLGizmoBase::render_grabbers(float size) const
{ {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
shader->start_using(); shader->start_using();
@ -153,11 +153,11 @@ void GLGizmoBase::render_grabbers(float size) const
void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
{ {
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL

View File

@ -49,9 +49,9 @@ protected:
bool dragging{ false }; bool dragging{ false };
Vec3d center{ Vec3d::Zero() }; Vec3d center{ Vec3d::Zero() };
Vec3d angles{ Vec3d::Zero() }; Vec3d angles{ Vec3d::Zero() };
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
Transform3d matrix{ Transform3d::Identity() }; Transform3d matrix{ Transform3d::Identity() };
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
ColorRGBA color{ ColorRGBA::WHITE() }; ColorRGBA color{ ColorRGBA::WHITE() };
Grabber() = default; Grabber() = default;

View File

@ -107,11 +107,11 @@ 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_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
const Vec3d diff = plane_center - m_old_center; const Vec3d diff = plane_center - m_old_center;
@ -144,11 +144,11 @@ void GLGizmoCut::on_render()
m_plane.init_from(std::move(init_data)); m_plane.init_from(std::move(init_data));
} }
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_plane.render(); m_plane.render();
#else #else
@ -197,11 +197,11 @@ void GLGizmoCut::on_render()
shader->stop_using(); shader->stop_using();
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
shader = wxGetApp().get_shader("gouraud_light_attr"); shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
shader = wxGetApp().get_shader("gouraud_light"); shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#else #else
glsafe(::glColor3f(1.0, 1.0, 0.0)); glsafe(::glColor3f(1.0, 1.0, 0.0));
::glBegin(GL_LINES); ::glBegin(GL_LINES);
@ -222,27 +222,27 @@ void GLGizmoCut::on_render()
} }
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
shader = wxGetApp().get_shader("flat_attr"); shader = wxGetApp().get_shader("flat_attr");
#else #else
shader = wxGetApp().get_shader("flat"); shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_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()* Geometry::assemble_transform(m_cut_contours.shift)); shader->set_uniform("view_model_matrix", camera.get_view_matrix()* Geometry::assemble_transform(m_cut_contours.shift));
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glTranslated(m_cut_contours.shift.x(), m_cut_contours.shift.y(), m_cut_contours.shift.z())); glsafe(::glTranslated(m_cut_contours.shift.x(), m_cut_contours.shift.y(), m_cut_contours.shift.z()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glLineWidth(2.0f)); glsafe(::glLineWidth(2.0f));
m_cut_contours.contours.render(); m_cut_contours.contours.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
shader->stop_using(); shader->stop_using();
} }

View File

@ -4,9 +4,9 @@
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/GUI_App.hpp"
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
#include "slic3r/GUI/Plater.hpp" #include "slic3r/GUI/Plater.hpp"
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp" #include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
@ -105,11 +105,11 @@ void GLGizmoFlatten::on_render()
const Selection& selection = m_parent.get_selection(); const Selection& selection = m_parent.get_selection();
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -123,7 +123,7 @@ void GLGizmoFlatten::on_render()
if (selection.is_single_full_instance()) { if (selection.is_single_full_instance()) {
const Transform3d& m = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(); const Transform3d& m = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Transform3d view_model_matrix = camera.get_view_matrix() * const Transform3d view_model_matrix = camera.get_view_matrix() *
Geometry::assemble_transform(selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z() * Vec3d::UnitZ()) * m; Geometry::assemble_transform(selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z() * Vec3d::UnitZ()) * m;
@ -134,7 +134,7 @@ void GLGizmoFlatten::on_render()
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glTranslatef(0.f, 0.f, selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z())); glsafe(::glTranslatef(0.f, 0.f, selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z()));
glsafe(::glMultMatrixd(m.data())); glsafe(::glMultMatrixd(m.data()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (this->is_plane_update_necessary()) if (this->is_plane_update_necessary())
update_planes(); update_planes();
for (int i = 0; i < (int)m_planes.size(); ++i) { for (int i = 0; i < (int)m_planes.size(); ++i) {
@ -147,9 +147,9 @@ void GLGizmoFlatten::on_render()
m_planes[i].vbo.render(); m_planes[i].vbo.render();
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
} }
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
glsafe(::glEnable(GL_CULL_FACE)); glsafe(::glEnable(GL_CULL_FACE));
@ -165,11 +165,11 @@ void GLGizmoFlatten::on_render_for_picking()
const Selection& selection = m_parent.get_selection(); const Selection& selection = m_parent.get_selection();
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -181,7 +181,7 @@ void GLGizmoFlatten::on_render_for_picking()
if (selection.is_single_full_instance() && !wxGetKeyState(WXK_CONTROL)) { if (selection.is_single_full_instance() && !wxGetKeyState(WXK_CONTROL)) {
const Transform3d& m = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix(); const Transform3d& m = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Transform3d view_model_matrix = camera.get_view_matrix() * const Transform3d view_model_matrix = camera.get_view_matrix() *
Geometry::assemble_transform(selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z() * Vec3d::UnitZ()) * m; Geometry::assemble_transform(selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z() * Vec3d::UnitZ()) * m;
@ -192,7 +192,7 @@ void GLGizmoFlatten::on_render_for_picking()
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glTranslatef(0.f, 0.f, selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z())); glsafe(::glTranslatef(0.f, 0.f, selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z()));
glsafe(::glMultMatrixd(m.data())); glsafe(::glMultMatrixd(m.data()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (this->is_plane_update_necessary()) if (this->is_plane_update_necessary())
update_planes(); update_planes();
for (int i = 0; i < (int)m_planes.size(); ++i) { for (int i = 0; i < (int)m_planes.size(); ++i) {
@ -203,9 +203,9 @@ void GLGizmoFlatten::on_render_for_picking()
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
m_planes[i].vbo.render(); m_planes[i].vbo.render();
} }
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
glsafe(::glEnable(GL_CULL_FACE)); glsafe(::glEnable(GL_CULL_FACE));

View File

@ -104,11 +104,11 @@ void GLGizmoHollow::on_render_for_picking()
void GLGizmoHollow::render_points(const Selection& selection, bool picking) void GLGizmoHollow::render_points(const Selection& selection, bool picking)
{ {
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = picking ? wxGetApp().get_shader("flat_attr") : wxGetApp().get_shader("gouraud_light_attr"); GLShaderProgram* shader = picking ? wxGetApp().get_shader("flat_attr") : wxGetApp().get_shader("gouraud_light_attr");
#else #else
GLShaderProgram* shader = picking ? wxGetApp().get_shader("flat") : wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = picking ? wxGetApp().get_shader("flat") : wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -122,7 +122,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking)
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin());
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d instance_scaling_matrix_inverse = vol->get_instance_transformation().get_matrix(true, true, false, true).inverse(); const Transform3d instance_scaling_matrix_inverse = vol->get_instance_transformation().get_matrix(true, true, false, true).inverse();
const Transform3d instance_matrix = Geometry::assemble_transform(m_c->selection_info()->get_sla_shift() * Vec3d::UnitZ()) * vol->get_instance_transformation().get_matrix(); const Transform3d instance_matrix = Geometry::assemble_transform(m_c->selection_info()->get_sla_shift() * Vec3d::UnitZ()) * vol->get_instance_transformation().get_matrix();
@ -138,7 +138,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking)
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glTranslated(0.0, 0.0, m_c->selection_info()->get_sla_shift())); glsafe(::glTranslated(0.0, 0.0, m_c->selection_info()->get_sla_shift()));
glsafe(::glMultMatrixd(instance_matrix.data())); glsafe(::glMultMatrixd(instance_matrix.data()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
ColorRGBA render_color; ColorRGBA render_color;
const sla::DrainHoles& drain_holes = m_c->selection_info()->model_object()->sla_drain_holes; const sla::DrainHoles& drain_holes = m_c->selection_info()->model_object()->sla_drain_holes;
@ -173,13 +173,13 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking)
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d hole_matrix = Geometry::assemble_transform(drain_hole.pos.cast<double>()) * instance_scaling_matrix_inverse; const Transform3d hole_matrix = Geometry::assemble_transform(drain_hole.pos.cast<double>()) * instance_scaling_matrix_inverse;
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glTranslatef(drain_hole.pos.x(), drain_hole.pos.y(), drain_hole.pos.z())); glsafe(::glTranslatef(drain_hole.pos.x(), drain_hole.pos.y(), drain_hole.pos.z()));
glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data())); glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (vol->is_left_handed()) if (vol->is_left_handed())
glFrontFace(GL_CW); glFrontFace(GL_CW);
@ -188,7 +188,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking)
Eigen::Quaterniond q; Eigen::Quaterniond q;
q.setFromTwoVectors(Vec3d::UnitZ(), instance_scaling_matrix_inverse * (-drain_hole.normal).cast<double>()); q.setFromTwoVectors(Vec3d::UnitZ(), instance_scaling_matrix_inverse * (-drain_hole.normal).cast<double>());
const Eigen::AngleAxisd aa(q); const Eigen::AngleAxisd aa(q);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d view_model_matrix = view_matrix * instance_matrix * hole_matrix * Transform3d(aa.toRotationMatrix()) * const Transform3d view_model_matrix = view_matrix * instance_matrix * hole_matrix * Transform3d(aa.toRotationMatrix()) *
Geometry::assemble_transform(-drain_hole.height * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength)); Geometry::assemble_transform(-drain_hole.height * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength));
@ -198,20 +198,20 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking)
glsafe(::glRotated(aa.angle() * (180. / M_PI), aa.axis().x(), aa.axis().y(), aa.axis().z())); glsafe(::glRotated(aa.angle() * (180. / M_PI), aa.axis().x(), aa.axis().y(), aa.axis().z()));
glsafe(::glTranslated(0., 0., -drain_hole.height)); glsafe(::glTranslated(0., 0., -drain_hole.height));
glsafe(::glScaled(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength)); glsafe(::glScaled(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_cylinder.render(); m_cylinder.render();
if (vol->is_left_handed()) if (vol->is_left_handed())
glFrontFace(GL_CCW); glFrontFace(GL_CCW);
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
bool GLGizmoHollow::is_mesh_point_clipped(const Vec3d& point) const bool GLGizmoHollow::is_mesh_point_clipped(const Vec3d& point) const

View File

@ -170,11 +170,11 @@ void GLGizmoMmuSegmentation::data_changed()
void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const
{ {
ClippingPlaneDataWrapper clp_data = this->get_clipping_plane_data(); ClippingPlaneDataWrapper clp_data = this->get_clipping_plane_data();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
auto* shader = wxGetApp().get_shader("mm_gouraud_attr"); auto* shader = wxGetApp().get_shader("mm_gouraud_attr");
#else #else
auto *shader = wxGetApp().get_shader("mm_gouraud"); auto *shader = wxGetApp().get_shader("mm_gouraud");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (!shader) if (!shader)
return; return;
shader->start_using(); shader->start_using();
@ -196,7 +196,7 @@ void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const
if (is_left_handed) if (is_left_handed)
glsafe(::glFrontFace(GL_CW)); glsafe(::glFrontFace(GL_CW));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Transform3d matrix = camera.get_view_matrix() * trafo_matrix; const Transform3d matrix = camera.get_view_matrix() * trafo_matrix;
shader->set_uniform("view_model_matrix", matrix); shader->set_uniform("view_model_matrix", matrix);
@ -205,19 +205,19 @@ void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glMultMatrixd(trafo_matrix.data())); glsafe(::glMultMatrixd(trafo_matrix.data()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
shader->set_uniform("volume_world_matrix", trafo_matrix); shader->set_uniform("volume_world_matrix", trafo_matrix);
shader->set_uniform("volume_mirrored", is_left_handed); shader->set_uniform("volume_mirrored", is_left_handed);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
m_triangle_selectors[mesh_id]->render(m_imgui, trafo_matrix); m_triangle_selectors[mesh_id]->render(m_imgui, trafo_matrix);
#else #else
m_triangle_selectors[mesh_id]->render(m_imgui); m_triangle_selectors[mesh_id]->render(m_imgui);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
if (is_left_handed) if (is_left_handed)
glsafe(::glFrontFace(GL_CCW)); glsafe(::glFrontFace(GL_CCW));
} }
@ -586,11 +586,11 @@ ColorRGBA GLGizmoMmuSegmentation::get_cursor_sphere_right_button_color() const
return color; return color;
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void TriangleSelectorMmGui::render(ImGuiWrapper* imgui, const Transform3d& matrix) void TriangleSelectorMmGui::render(ImGuiWrapper* imgui, const Transform3d& matrix)
#else #else
void TriangleSelectorMmGui::render(ImGuiWrapper *imgui) void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
if (m_update_render_data) if (m_update_render_data)
update_render_data(); update_render_data();
@ -598,11 +598,11 @@ void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
auto *shader = wxGetApp().get_current_shader(); auto *shader = wxGetApp().get_current_shader();
if (!shader) if (!shader)
return; return;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
assert(shader->get_name() == "mm_gouraud_attr"); assert(shader->get_name() == "mm_gouraud_attr");
#else #else
assert(shader->get_name() == "mm_gouraud"); assert(shader->get_name() == "mm_gouraud");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
for (size_t color_idx = 0; color_idx < m_gizmo_scene.triangle_indices.size(); ++color_idx) for (size_t color_idx = 0; color_idx < m_gizmo_scene.triangle_indices.size(); ++color_idx)
if (m_gizmo_scene.has_VBOs(color_idx)) { if (m_gizmo_scene.has_VBOs(color_idx)) {
@ -615,11 +615,11 @@ void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
} }
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_paint_contour(matrix); render_paint_contour(matrix);
#else #else
render_paint_contour(); render_paint_contour();
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#else #else
if (m_paint_contour.has_VBO()) { if (m_paint_contour.has_VBO()) {
ScopeGuard guard_mm_gouraud([shader]() { shader->start_using(); }); ScopeGuard guard_mm_gouraud([shader]() { shader->start_using(); });

View File

@ -66,13 +66,13 @@ public:
: TriangleSelectorGUI(mesh), m_colors(colors), m_default_volume_color(default_volume_color), m_gizmo_scene(2 * (colors.size() + 1)) {} : TriangleSelectorGUI(mesh), m_colors(colors), m_default_volume_color(default_volume_color), m_gizmo_scene(2 * (colors.size() + 1)) {}
~TriangleSelectorMmGui() override = default; ~TriangleSelectorMmGui() override = default;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void render(ImGuiWrapper* imgui, const Transform3d& matrix) override; void render(ImGuiWrapper* imgui, const Transform3d& matrix) override;
#else #else
// Render current selection. Transformation matrices are supposed // Render current selection. Transformation matrices are supposed
// to be already set. // to be already set.
void render(ImGuiWrapper* imgui) override; void render(ImGuiWrapper* imgui) override;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
private: private:
void update_render_data(); void update_render_data();

View File

@ -2,9 +2,9 @@
#include "GLGizmoMove.hpp" #include "GLGizmoMove.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp" #include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/GUI_App.hpp"
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
#include "slic3r/GUI/Plater.hpp" #include "slic3r/GUI/Plater.hpp"
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#include <GL/glew.h> #include <GL/glew.h>
@ -154,20 +154,20 @@ 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_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// draw axes // draw axes
for (unsigned int i = 0; i < 3; ++i) { for (unsigned int i = 0; i < 3; ++i) {
@ -199,29 +199,29 @@ void GLGizmoMove3D::on_render()
else { else {
// draw axis // draw axis
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
render_grabber_connection(m_hover_id); render_grabber_connection(m_hover_id);
shader->stop_using(); shader->stop_using();
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
shader = wxGetApp().get_shader("gouraud_light_attr"); shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
shader = wxGetApp().get_shader("gouraud_light"); shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#else #else
glsafe(::glColor4fv(AXES_COLOR[m_hover_id].data())); glsafe(::glColor4fv(AXES_COLOR[m_hover_id].data()));
::glBegin(GL_LINES); ::glBegin(GL_LINES);
@ -286,11 +286,11 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
const double size = m_dragging ? double(m_grabbers[axis].get_dragging_half_size(mean_size)) : double(m_grabbers[axis].get_half_size(mean_size)); const double size = m_dragging ? double(m_grabbers[axis].get_dragging_half_size(mean_size)) : double(m_grabbers[axis].get_half_size(mean_size));
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat_attr" : "gouraud_light_attr"); GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat_attr" : "gouraud_light_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat" : "gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat" : "gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
@ -309,7 +309,7 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
} }
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
Transform3d view_model_matrix = camera.get_view_matrix() * Geometry::assemble_transform(m_grabbers[axis].center); Transform3d view_model_matrix = camera.get_view_matrix() * Geometry::assemble_transform(m_grabbers[axis].center);
if (axis == X) if (axis == X)
@ -331,11 +331,11 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
glsafe(::glTranslated(0.0, 0.0, 2.0 * size)); glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size)); glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_cone.render(); m_cone.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
#if !ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_LEGACY_OPENGL_REMOVAL
if (! picking) if (! picking)

View File

@ -80,11 +80,11 @@ GLGizmoPainterBase::ClippingPlaneDataWrapper GLGizmoPainterBase::get_clipping_pl
void GLGizmoPainterBase::render_triangles(const Selection& selection) const void GLGizmoPainterBase::render_triangles(const Selection& selection) const
{ {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
auto* shader = wxGetApp().get_shader("gouraud_attr"); auto* shader = wxGetApp().get_shader("gouraud_attr");
#else #else
auto* shader = wxGetApp().get_shader("gouraud"); auto* shader = wxGetApp().get_shader("gouraud");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (! shader) if (! shader)
return; return;
shader->start_using(); shader->start_using();
@ -109,7 +109,7 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const
if (is_left_handed) if (is_left_handed)
glsafe(::glFrontFace(GL_CW)); glsafe(::glFrontFace(GL_CW));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Transform3d matrix = camera.get_view_matrix() * trafo_matrix; const Transform3d matrix = camera.get_view_matrix() * trafo_matrix;
shader->set_uniform("view_model_matrix", matrix); shader->set_uniform("view_model_matrix", matrix);
@ -118,7 +118,7 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glMultMatrixd(trafo_matrix.data())); glsafe(::glMultMatrixd(trafo_matrix.data()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// For printers with multiple extruders, it is necessary to pass trafo_matrix // For printers with multiple extruders, it is necessary to pass trafo_matrix
// to the shader input variable print_box.volume_world_matrix before // to the shader input variable print_box.volume_world_matrix before
@ -126,13 +126,13 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const
// wrong transformation matrix is used for "Clipping of view". // wrong transformation matrix is used for "Clipping of view".
shader->set_uniform("volume_world_matrix", trafo_matrix); shader->set_uniform("volume_world_matrix", trafo_matrix);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
m_triangle_selectors[mesh_id]->render(m_imgui, trafo_matrix); m_triangle_selectors[mesh_id]->render(m_imgui, trafo_matrix);
#else #else
m_triangle_selectors[mesh_id]->render(m_imgui); m_triangle_selectors[mesh_id]->render(m_imgui);
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (is_left_handed) if (is_left_handed)
glsafe(::glFrontFace(GL_CCW)); glsafe(::glFrontFace(GL_CCW));
} }
@ -167,14 +167,14 @@ void GLGizmoPainterBase::render_cursor()
void GLGizmoPainterBase::render_cursor_circle() void GLGizmoPainterBase::render_cursor_circle()
{ {
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
const Camera &camera = wxGetApp().plater()->get_camera(); const Camera &camera = wxGetApp().plater()->get_camera();
const float zoom = float(camera.get_zoom()); const float zoom = float(camera.get_zoom());
const float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; const float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
const Size cnv_size = m_parent.get_canvas_size(); const Size cnv_size = m_parent.get_canvas_size();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const float cnv_width = float(cnv_size.get_width()); const float cnv_width = float(cnv_size.get_width());
const float cnv_height = float(cnv_size.get_height()); const float cnv_height = float(cnv_size.get_height());
if (cnv_width == 0.0f || cnv_height == 0.0f) if (cnv_width == 0.0f || cnv_height == 0.0f)
@ -193,7 +193,7 @@ void GLGizmoPainterBase::render_cursor_circle()
const Vec2d mouse_pos(m_parent.get_local_mouse_position().x(), m_parent.get_local_mouse_position().y()); const Vec2d mouse_pos(m_parent.get_local_mouse_position().x(), m_parent.get_local_mouse_position().y());
Vec2d center(mouse_pos.x() - cnv_half_width, cnv_half_height - mouse_pos.y()); Vec2d center(mouse_pos.x() - cnv_half_width, cnv_half_height - mouse_pos.y());
center = center * inv_zoom; center = center * inv_zoom;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glLineWidth(1.5f)); glsafe(::glLineWidth(1.5f));
#if !ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_LEGACY_OPENGL_REMOVAL
@ -202,7 +202,7 @@ void GLGizmoPainterBase::render_cursor_circle()
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL #endif // !ENABLE_LEGACY_OPENGL_REMOVAL
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glLoadIdentity()); glsafe(::glLoadIdentity());
// ensure that the circle is renderered inside the frustrum // ensure that the circle is renderered inside the frustrum
@ -210,20 +210,20 @@ void GLGizmoPainterBase::render_cursor_circle()
// ensure that the overlay fits the frustrum near z plane // ensure that the overlay fits the frustrum near z plane
const double gui_scale = camera.get_gui_scale(); const double gui_scale = camera.get_gui_scale();
glsafe(::glScaled(gui_scale, gui_scale, 1.0)); glsafe(::glScaled(gui_scale, gui_scale, 1.0));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPushAttrib(GL_ENABLE_BIT)); glsafe(::glPushAttrib(GL_ENABLE_BIT));
glsafe(::glLineStipple(4, 0xAAAA)); glsafe(::glLineStipple(4, 0xAAAA));
glsafe(::glEnable(GL_LINE_STIPPLE)); glsafe(::glEnable(GL_LINE_STIPPLE));
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (!m_circle.is_initialized() || !m_old_center.isApprox(center) || std::abs(m_old_cursor_radius - radius) > EPSILON) { if (!m_circle.is_initialized() || !m_old_center.isApprox(center) || std::abs(m_old_cursor_radius - radius) > EPSILON) {
m_old_cursor_radius = radius; m_old_cursor_radius = radius;
#else #else
if (!m_circle.is_initialized() || !m_old_center.isApprox(center) || std::abs(m_old_cursor_radius - m_cursor_radius) > EPSILON) { if (!m_circle.is_initialized() || !m_old_center.isApprox(center) || std::abs(m_old_cursor_radius - m_cursor_radius) > EPSILON) {
m_old_cursor_radius = m_cursor_radius; m_old_cursor_radius = m_cursor_radius;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_old_center = center; m_old_center = center;
m_circle.reset(); m_circle.reset();
@ -238,29 +238,29 @@ void GLGizmoPainterBase::render_cursor_circle()
// vertices + indices // vertices + indices
for (unsigned short i = 0; i < StepsCount; ++i) { for (unsigned short i = 0; i < StepsCount; ++i) {
const float angle = float(i * StepSize); const float angle = float(i * StepSize);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
init_data.add_vertex(Vec2f(2.0f * ((center.x() + ::cos(angle) * radius) * cnv_inv_width - 0.5f), init_data.add_vertex(Vec2f(2.0f * ((center.x() + ::cos(angle) * radius) * cnv_inv_width - 0.5f),
-2.0f * ((center.y() + ::sin(angle) * radius) * cnv_inv_height - 0.5f))); -2.0f * ((center.y() + ::sin(angle) * radius) * cnv_inv_height - 0.5f)));
#else #else
init_data.add_vertex(Vec2f(center.x() + ::cos(angle) * m_cursor_radius, center.y() + ::sin(angle) * m_cursor_radius)); init_data.add_vertex(Vec2f(center.x() + ::cos(angle) * m_cursor_radius, center.y() + ::sin(angle) * m_cursor_radius));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
init_data.add_ushort_index(i); init_data.add_ushort_index(i);
} }
m_circle.init_from(std::move(init_data)); m_circle.init_from(std::move(init_data));
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = GUI::wxGetApp().get_shader("flat"); GLShaderProgram* shader = GUI::wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_circle.render(); m_circle.render();
shader->stop_using(); shader->stop_using();
} }
@ -272,9 +272,9 @@ void GLGizmoPainterBase::render_cursor_circle()
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
glsafe(::glPopAttrib()); glsafe(::glPopAttrib());
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
} }
@ -292,25 +292,25 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
const Transform3d complete_scaling_matrix_inverse = Geometry::Transformation(trafo).get_matrix(true, true, false, true).inverse(); const Transform3d complete_scaling_matrix_inverse = Geometry::Transformation(trafo).get_matrix(true, true, false, true).inverse();
const bool is_left_handed = Geometry::Transformation(trafo).is_left_handed(); const bool is_left_handed = Geometry::Transformation(trafo).is_left_handed();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glMultMatrixd(trafo.data())); glsafe(::glMultMatrixd(trafo.data()));
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
glsafe(::glTranslatef(m_rr.hit.x(), m_rr.hit.y(), m_rr.hit.z())); glsafe(::glTranslatef(m_rr.hit.x(), m_rr.hit.y(), m_rr.hit.z()));
glsafe(::glMultMatrixd(complete_scaling_matrix_inverse.data())); glsafe(::glMultMatrixd(complete_scaling_matrix_inverse.data()));
glsafe(::glScaled(m_cursor_radius, m_cursor_radius, m_cursor_radius)); glsafe(::glScaled(m_cursor_radius, m_cursor_radius, m_cursor_radius));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
if (is_left_handed) if (is_left_handed)
glFrontFace(GL_CW); glFrontFace(GL_CW);
@ -323,7 +323,7 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
Transform3d view_model_matrix = camera.get_view_matrix() * trafo * Transform3d view_model_matrix = camera.get_view_matrix() * trafo *
Geometry::assemble_transform(m_rr.hit.cast<double>()) * complete_scaling_matrix_inverse * Geometry::assemble_transform(m_rr.hit.cast<double>()) * complete_scaling_matrix_inverse *
@ -331,7 +331,7 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
assert(s_sphere != nullptr); assert(s_sphere != nullptr);
s_sphere->set_color(render_color); s_sphere->set_color(render_color);
@ -349,9 +349,9 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
if (is_left_handed) if (is_left_handed)
glFrontFace(GL_CCW); glFrontFace(GL_CCW);
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
@ -910,11 +910,11 @@ ColorRGBA TriangleSelectorGUI::get_seed_fill_color(const ColorRGBA& base_color)
return saturate(base_color, 0.75f); return saturate(base_color, 0.75f);
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void TriangleSelectorGUI::render(ImGuiWrapper* imgui, const Transform3d& matrix) void TriangleSelectorGUI::render(ImGuiWrapper* imgui, const Transform3d& matrix)
#else #else
void TriangleSelectorGUI::render(ImGuiWrapper* imgui) void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
static const ColorRGBA enforcers_color = { 0.47f, 0.47f, 1.0f, 1.0f }; static const ColorRGBA enforcers_color = { 0.47f, 0.47f, 1.0f, 1.0f };
static const ColorRGBA blockers_color = { 1.0f, 0.44f, 0.44f, 1.0f }; static const ColorRGBA blockers_color = { 1.0f, 0.44f, 0.44f, 1.0f };
@ -927,11 +927,11 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
auto* shader = wxGetApp().get_current_shader(); auto* shader = wxGetApp().get_current_shader();
if (! shader) if (! shader)
return; return;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
assert(shader->get_name() == "gouraud_attr"); assert(shader->get_name() == "gouraud_attr");
#else #else
assert(shader->get_name() == "gouraud"); assert(shader->get_name() == "gouraud");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
ScopeGuard guard([shader]() { if (shader) shader->set_uniform("offset_depth_buffer", false);}); ScopeGuard guard([shader]() { if (shader) shader->set_uniform("offset_depth_buffer", false);});
shader->set_uniform("offset_depth_buffer", true); shader->set_uniform("offset_depth_buffer", true);
for (auto iva : {std::make_pair(&m_iva_enforcers, enforcers_color), for (auto iva : {std::make_pair(&m_iva_enforcers, enforcers_color),
@ -969,11 +969,11 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_paint_contour(matrix); render_paint_contour(matrix);
#else #else
render_paint_contour(); render_paint_contour();
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#else #else
if (m_paint_contour.has_VBO()) { if (m_paint_contour.has_VBO()) {
ScopeGuard guard_gouraud([shader]() { shader->start_using(); }); ScopeGuard guard_gouraud([shader]() { shader->start_using(); });
@ -1288,19 +1288,19 @@ void TriangleSelectorGUI::render_debug(ImGuiWrapper* imgui)
if (curr_shader != nullptr) if (curr_shader != nullptr)
curr_shader->stop_using(); curr_shader->stop_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
::glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); ::glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
@ -1348,9 +1348,9 @@ void TriangleSelectorGUI::update_paint_contour()
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::index_type(2 * contour_edges.size()) }; init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::index_type(2 * contour_edges.size()) };
init_data.reserve_vertices(2 * contour_edges.size()); init_data.reserve_vertices(2 * contour_edges.size());
init_data.reserve_indices(2 * contour_edges.size()); init_data.reserve_indices(2 * contour_edges.size());
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
init_data.color = ColorRGBA::WHITE(); init_data.color = ColorRGBA::WHITE();
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
// //
// vertices + indices // vertices + indices
unsigned int vertices_count = 0; unsigned int vertices_count = 0;
@ -1368,29 +1368,29 @@ void TriangleSelectorGUI::update_paint_contour()
m_paint_contour.init_from(std::move(init_data)); m_paint_contour.init_from(std::move(init_data));
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void TriangleSelectorGUI::render_paint_contour(const Transform3d& matrix) void TriangleSelectorGUI::render_paint_contour(const Transform3d& matrix)
#else #else
void TriangleSelectorGUI::render_paint_contour() void TriangleSelectorGUI::render_paint_contour()
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
auto* curr_shader = wxGetApp().get_current_shader(); auto* curr_shader = wxGetApp().get_current_shader();
if (curr_shader != nullptr) if (curr_shader != nullptr)
curr_shader->stop_using(); curr_shader->stop_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
auto* contour_shader = wxGetApp().get_shader("mm_contour_attr"); auto* contour_shader = wxGetApp().get_shader("mm_contour_attr");
#else #else
auto* contour_shader = wxGetApp().get_shader("mm_contour"); auto* contour_shader = wxGetApp().get_shader("mm_contour");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (contour_shader != nullptr) { if (contour_shader != nullptr) {
contour_shader->start_using(); contour_shader->start_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
contour_shader->set_uniform("view_model_matrix", camera.get_view_matrix() * matrix); contour_shader->set_uniform("view_model_matrix", camera.get_view_matrix() * matrix);
contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix()); contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glDepthFunc(GL_LEQUAL)); glsafe(::glDepthFunc(GL_LEQUAL));
m_paint_contour.render(); m_paint_contour.render();

View File

@ -77,7 +77,7 @@ public:
: TriangleSelector(mesh) {} : TriangleSelector(mesh) {}
virtual ~TriangleSelectorGUI() = default; virtual ~TriangleSelectorGUI() = default;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
virtual void render(ImGuiWrapper* imgui, const Transform3d& matrix); virtual void render(ImGuiWrapper* imgui, const Transform3d& matrix);
void render(const Transform3d& matrix) { this->render(nullptr, matrix); } void render(const Transform3d& matrix) { this->render(nullptr, matrix); }
#else #else
@ -85,7 +85,7 @@ public:
// to be already set. // to be already set.
virtual void render(ImGuiWrapper *imgui); virtual void render(ImGuiWrapper *imgui);
void render() { this->render(nullptr); } void render() { this->render(nullptr); }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void request_update_render_data() { m_update_render_data = true; } void request_update_render_data() { m_update_render_data = true; }
@ -122,11 +122,11 @@ protected:
GLModel m_paint_contour; GLModel m_paint_contour;
void update_paint_contour(); void update_paint_contour();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void render_paint_contour(const Transform3d& matrix); void render_paint_contour(const Transform3d& matrix);
#else #else
void render_paint_contour(); void render_paint_contour();
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#else #else
GLPaintContour m_paint_contour; GLPaintContour m_paint_contour;
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL

View File

@ -163,30 +163,30 @@ void GLGizmoRotate::on_render()
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
m_grabbers.front().matrix = local_transform(selection); m_grabbers.front().matrix = local_transform(selection);
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
transform_to_local(selection); transform_to_local(selection);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f)); glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
Transform3d view_model_matrix = camera.get_view_matrix() * m_grabbers.front().matrix; 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());
#endif // ENABLE_GLBEGIN_GLEND_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;
@ -223,10 +223,10 @@ void GLGizmoRotate::on_render()
render_angle(); render_angle();
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
transform_to_local(selection); transform_to_local(selection);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
render_grabber(box); render_grabber(box);
render_grabber_extension(box, false); render_grabber_extension(box, false);
@ -240,20 +240,20 @@ void GLGizmoRotate::on_render_for_picking()
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
m_grabbers.front().matrix = local_transform(selection); m_grabbers.front().matrix = local_transform(selection);
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
transform_to_local(selection); transform_to_local(selection);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
const BoundingBoxf3& box = selection.get_bounding_box(); const BoundingBoxf3& box = selection.get_bounding_box();
render_grabbers_for_picking(box); render_grabbers_for_picking(box);
render_grabber_extension(box, true); render_grabber_extension(box, true);
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
void GLGizmoRotate3D::on_render_input_window(float x, float y, float bottom_limit) void GLGizmoRotate3D::on_render_input_window(float x, float y, float bottom_limit)
@ -576,11 +576,11 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
const double size = m_dragging ? double(m_grabbers.front().get_dragging_half_size(mean_size)) : double(m_grabbers.front().get_half_size(mean_size)); const double size = m_dragging ? double(m_grabbers.front().get_dragging_half_size(mean_size)) : double(m_grabbers.front().get_half_size(mean_size));
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat_attr" : "gouraud_light_attr"); GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat_attr" : "gouraud_light_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat" : "gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat" : "gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -602,7 +602,7 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
const Vec3d& center = m_grabbers.front().center; const Vec3d& center = m_grabbers.front().center;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Transform3d& view_matrix = camera.get_view_matrix(); const Transform3d& view_matrix = camera.get_view_matrix();
shader->set_uniform("projection_matrix", camera.get_projection_matrix()); shader->set_uniform("projection_matrix", camera.get_projection_matrix());
@ -620,9 +620,9 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
glsafe(::glRotated(90.0, 1.0, 0.0, 0.0)); glsafe(::glRotated(90.0, 1.0, 0.0, 0.0));
glsafe(::glTranslated(0.0, 0.0, 2.0 * size)); glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size)); glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_cone.render(); m_cone.render();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
view_model_matrix = view_matrix * m_grabbers.front().matrix * view_model_matrix = view_matrix * m_grabbers.front().matrix *
Geometry::assemble_transform(center, Vec3d(-0.5 * PI, 0.0, m_angle)) * Geometry::assemble_transform(center, Vec3d(-0.5 * PI, 0.0, m_angle)) *
Geometry::assemble_transform(2.0 * size * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(0.75 * size, 0.75 * size, 3.0 * size)); Geometry::assemble_transform(2.0 * size * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(0.75 * size, 0.75 * size, 3.0 * size));
@ -637,11 +637,11 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0)); glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
glsafe(::glTranslated(0.0, 0.0, 2.0 * size)); glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size)); glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_cone.render(); m_cone.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
#if !ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_LEGACY_OPENGL_REMOVAL
if (! picking) if (! picking)
@ -649,7 +649,7 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
shader->stop_using(); shader->stop_using();
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
Transform3d GLGizmoRotate::local_transform(const Selection& selection) const Transform3d GLGizmoRotate::local_transform(const Selection& selection) const
{ {
Transform3d ret; Transform3d ret;
@ -679,7 +679,7 @@ Transform3d GLGizmoRotate::local_transform(const Selection& selection) const
return Geometry::assemble_transform(m_center) * ret; return Geometry::assemble_transform(m_center) * ret;
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void GLGizmoRotate::transform_to_local(const Selection& selection) const void GLGizmoRotate::transform_to_local(const Selection& selection) const
{ {

View File

@ -106,9 +106,9 @@ private:
void render_grabber(const BoundingBoxf3& box); void render_grabber(const BoundingBoxf3& box);
void render_grabber_extension(const BoundingBoxf3& box, bool picking); void render_grabber_extension(const BoundingBoxf3& box, bool picking);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
Transform3d local_transform(const Selection& selection) const; Transform3d local_transform(const Selection& selection) const;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void transform_to_local(const Selection& selection) const; void transform_to_local(const Selection& selection) const;
// returns the intersection of the mouse ray with the plane perpendicular to the gizmo axis, in local coordinate // returns the intersection of the mouse ray with the plane perpendicular to the gizmo axis, in local coordinate

View File

@ -2,9 +2,9 @@
#include "GLGizmoScale.hpp" #include "GLGizmoScale.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp" #include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/GUI_App.hpp"
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
#include "slic3r/GUI/Plater.hpp" #include "slic3r/GUI/Plater.hpp"
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#include <GL/glew.h> #include <GL/glew.h>
@ -265,18 +265,18 @@ 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_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_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);
if (m_grabbers[2].enabled && m_grabbers[3].enabled) if (m_grabbers[2].enabled && m_grabbers[3].enabled)
@ -316,28 +316,28 @@ 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_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_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();
} }
// draw grabbers // draw grabbers
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
shader = wxGetApp().get_shader("gouraud_light_attr"); shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
shader = wxGetApp().get_shader("gouraud_light"); shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#else #else
// draw connection // draw connection
glsafe(::glColor4fv(m_grabbers[0].color.data())); glsafe(::glColor4fv(m_grabbers[0].color.data()));
@ -357,28 +357,28 @@ 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_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_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();
} }
// draw grabbers // draw grabbers
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
shader = wxGetApp().get_shader("gouraud_light_attr"); shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
shader = wxGetApp().get_shader("gouraud_light"); shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#else #else
// draw connection // draw connection
glsafe(::glColor4fv(m_grabbers[2].color.data())); glsafe(::glColor4fv(m_grabbers[2].color.data()));
@ -398,28 +398,28 @@ 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_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_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();
} }
// draw grabbers // draw grabbers
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
shader = wxGetApp().get_shader("gouraud_light_attr"); shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
shader = wxGetApp().get_shader("gouraud_light"); shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#else #else
// draw connection // draw connection
glsafe(::glColor4fv(m_grabbers[4].color.data())); glsafe(::glColor4fv(m_grabbers[4].color.data()));
@ -439,18 +439,18 @@ 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_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_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);
render_grabbers_connection(8, 9, m_drag_color); render_grabbers_connection(8, 9, m_drag_color);
@ -459,11 +459,11 @@ void GLGizmoScale3D::on_render()
} }
// draw grabbers // draw grabbers
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
shader = wxGetApp().get_shader("gouraud_light_attr"); shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
shader = wxGetApp().get_shader("gouraud_light"); shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#else #else
// draw connection // draw connection
glsafe(::glColor4fv(m_drag_color.data())); glsafe(::glColor4fv(m_drag_color.data()));

View File

@ -737,53 +737,53 @@ void GLGizmoSimplify::on_render()
GLModel &glmodel = it->second; GLModel &glmodel = it->second;
const Transform3d trafo_matrix = selected_volume->world_matrix(); const Transform3d trafo_matrix = selected_volume->world_matrix();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
auto* gouraud_shader = wxGetApp().get_shader("gouraud_light_attr"); auto* gouraud_shader = wxGetApp().get_shader("gouraud_light_attr");
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glMultMatrixd(trafo_matrix.data())); glsafe(::glMultMatrixd(trafo_matrix.data()));
auto *gouraud_shader = wxGetApp().get_shader("gouraud_light"); auto *gouraud_shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPushAttrib(GL_DEPTH_TEST)); glsafe(::glPushAttrib(GL_DEPTH_TEST));
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
gouraud_shader->start_using(); gouraud_shader->start_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Transform3d view_model_matrix = camera.get_view_matrix() * trafo_matrix; const Transform3d view_model_matrix = camera.get_view_matrix() * trafo_matrix;
gouraud_shader->set_uniform("view_model_matrix", view_model_matrix); gouraud_shader->set_uniform("view_model_matrix", view_model_matrix);
gouraud_shader->set_uniform("projection_matrix", camera.get_projection_matrix()); gouraud_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
gouraud_shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); gouraud_shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glmodel.render(); glmodel.render();
gouraud_shader->stop_using(); gouraud_shader->stop_using();
if (m_show_wireframe) { if (m_show_wireframe) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
auto* contour_shader = wxGetApp().get_shader("mm_contour_attr"); auto* contour_shader = wxGetApp().get_shader("mm_contour_attr");
#else #else
auto *contour_shader = wxGetApp().get_shader("mm_contour"); auto *contour_shader = wxGetApp().get_shader("mm_contour");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
contour_shader->start_using(); contour_shader->start_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
contour_shader->set_uniform("view_model_matrix", view_model_matrix); contour_shader->set_uniform("view_model_matrix", view_model_matrix);
contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix()); contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
const ColorRGBA color = glmodel.get_color(); const ColorRGBA color = glmodel.get_color();
glmodel.set_color(ColorRGBA::WHITE()); glmodel.set_color(ColorRGBA::WHITE());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glLineWidth(1.0f)); glsafe(::glLineWidth(1.0f));
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)); glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_LINE));
glmodel.render(); glmodel.render();
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)); glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_FILL));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
glmodel.set_color(color); glmodel.set_color(color);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
contour_shader->stop_using(); contour_shader->stop_using();
} }
glsafe(::glPopAttrib()); glsafe(::glPopAttrib());
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
} }

View File

@ -130,11 +130,11 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
return; return;
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = picking ? wxGetApp().get_shader("flat_attr") : wxGetApp().get_shader("gouraud_light_attr"); GLShaderProgram* shader = picking ? wxGetApp().get_shader("flat_attr") : wxGetApp().get_shader("gouraud_light_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat" : "gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader(picking ? "flat" : "gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -152,7 +152,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin()); const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin());
const Transform3d instance_scaling_matrix_inverse = vol->get_instance_transformation().get_matrix(true, true, false, true).inverse(); const Transform3d instance_scaling_matrix_inverse = vol->get_instance_transformation().get_matrix(true, true, false, true).inverse();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d instance_matrix = Geometry::assemble_transform(m_c->selection_info()->get_sla_shift() * Vec3d::UnitZ()) * vol->get_instance_transformation().get_matrix(); const Transform3d instance_matrix = Geometry::assemble_transform(m_c->selection_info()->get_sla_shift() * Vec3d::UnitZ()) * vol->get_instance_transformation().get_matrix();
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
@ -167,7 +167,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glTranslated(0.0, 0.0, z_shift)); glsafe(::glTranslated(0.0, 0.0, z_shift));
glsafe(::glMultMatrixd(instance_matrix.data())); glsafe(::glMultMatrixd(instance_matrix.data()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
ColorRGBA render_color; ColorRGBA render_color;
for (size_t i = 0; i < cache_size; ++i) { for (size_t i = 0; i < cache_size; ++i) {
@ -211,13 +211,13 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
shader->set_uniform("emission_factor", 0.5f); shader->set_uniform("emission_factor", 0.5f);
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d support_matrix = Geometry::assemble_transform(support_point.pos.cast<double>()) * instance_scaling_matrix_inverse; const Transform3d support_matrix = Geometry::assemble_transform(support_point.pos.cast<double>()) * instance_scaling_matrix_inverse;
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glTranslatef(support_point.pos.x(), support_point.pos.y(), support_point.pos.z())); glsafe(::glTranslatef(support_point.pos.x(), support_point.pos.y(), support_point.pos.z()));
glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data())); glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (vol->is_left_handed()) if (vol->is_left_handed())
glFrontFace(GL_CW); glFrontFace(GL_CW);
@ -234,7 +234,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
const Eigen::AngleAxisd aa(q); const Eigen::AngleAxisd aa(q);
const double cone_radius = 0.25; // mm const double cone_radius = 0.25; // mm
const double cone_height = 0.75; const double cone_height = 0.75;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d view_model_matrix = view_matrix * instance_matrix * support_matrix * Transform3d(aa.toRotationMatrix()) * const Transform3d view_model_matrix = view_matrix * instance_matrix * support_matrix * Transform3d(aa.toRotationMatrix()) *
Geometry::assemble_transform((cone_height + support_point.head_front_radius * RenderPointScale) * Vec3d::UnitZ(), Geometry::assemble_transform((cone_height + support_point.head_front_radius * RenderPointScale) * Vec3d::UnitZ(),
Vec3d(PI, 0.0, 0.0), Vec3d(cone_radius, cone_radius, cone_height)); Vec3d(PI, 0.0, 0.0), Vec3d(cone_radius, cone_radius, cone_height));
@ -247,15 +247,15 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
glsafe(::glTranslatef(0.f, 0.f, cone_height + support_point.head_front_radius * RenderPointScale)); glsafe(::glTranslatef(0.f, 0.f, cone_height + support_point.head_front_radius * RenderPointScale));
glsafe(::glRotated(180., 1., 0., 0.)); glsafe(::glRotated(180., 1., 0., 0.));
glsafe(::glScaled(cone_radius, cone_radius, cone_height)); glsafe(::glScaled(cone_radius, cone_radius, cone_height));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_cone.render(); m_cone.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
const double radius = (double)support_point.head_front_radius * RenderPointScale; const double radius = (double)support_point.head_front_radius * RenderPointScale;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d view_model_matrix = view_matrix * instance_matrix * support_matrix * const Transform3d view_model_matrix = view_matrix * instance_matrix * support_matrix *
Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), radius * Vec3d::Ones()); Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), radius * Vec3d::Ones());
@ -264,18 +264,18 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glScaled(radius, radius, radius)); glsafe(::glScaled(radius, radius, radius));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_sphere.render(); m_sphere.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
if (vol->is_left_handed()) if (vol->is_left_handed())
glFrontFace(GL_CCW); glFrontFace(GL_CCW);
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
// Now render the drain holes: // Now render the drain holes:
@ -292,14 +292,14 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
if (is_mesh_point_clipped(drain_hole.pos.cast<double>())) if (is_mesh_point_clipped(drain_hole.pos.cast<double>()))
continue; continue;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d hole_matrix = Geometry::assemble_transform(drain_hole.pos.cast<double>()) * instance_scaling_matrix_inverse; const Transform3d hole_matrix = Geometry::assemble_transform(drain_hole.pos.cast<double>()) * instance_scaling_matrix_inverse;
#else #else
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object. // Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glTranslatef(drain_hole.pos.x(), drain_hole.pos.y(), drain_hole.pos.z())); glsafe(::glTranslatef(drain_hole.pos.x(), drain_hole.pos.y(), drain_hole.pos.z()));
glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data())); glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (vol->is_left_handed()) if (vol->is_left_handed())
glFrontFace(GL_CW); glFrontFace(GL_CW);
@ -308,7 +308,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
Eigen::Quaterniond q; Eigen::Quaterniond q;
q.setFromTwoVectors(Vec3d::UnitZ(), instance_scaling_matrix_inverse * (-drain_hole.normal).cast<double>()); q.setFromTwoVectors(Vec3d::UnitZ(), instance_scaling_matrix_inverse * (-drain_hole.normal).cast<double>());
const Eigen::AngleAxisd aa(q); const Eigen::AngleAxisd aa(q);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d view_model_matrix = view_matrix * instance_matrix * hole_matrix * Transform3d(aa.toRotationMatrix()) * const Transform3d view_model_matrix = view_matrix * instance_matrix * hole_matrix * Transform3d(aa.toRotationMatrix()) *
Geometry::assemble_transform(-drain_hole.height * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength)); Geometry::assemble_transform(-drain_hole.height * Vec3d::UnitZ(), Vec3d::Zero(), Vec3d(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength));
@ -318,20 +318,20 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
glsafe(::glRotated(aa.angle() * (180. / M_PI), aa.axis().x(), aa.axis().y(), aa.axis().z())); glsafe(::glRotated(aa.angle() * (180. / M_PI), aa.axis().x(), aa.axis().y(), aa.axis().z()));
glsafe(::glTranslated(0., 0., -drain_hole.height)); glsafe(::glTranslated(0., 0., -drain_hole.height));
glsafe(::glScaled(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength)); glsafe(::glScaled(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_cylinder.render(); m_cylinder.render();
if (vol->is_left_handed()) if (vol->is_left_handed())
glFrontFace(GL_CCW); glFrontFace(GL_CCW);
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
} }
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }

View File

@ -213,9 +213,9 @@ void InstancesHider::render_cut() const
else else
clipper->set_limiting_plane(ClippingPlane::ClipsNothing()); clipper->set_limiting_plane(ClippingPlane::ClipsNothing());
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
#if !ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_LEGACY_OPENGL_REMOVAL
if (mv->is_model_part()) if (mv->is_model_part())
glsafe(::glColor3f(0.8f, 0.3f, 0.0f)); glsafe(::glColor3f(0.8f, 0.3f, 0.0f));
@ -232,9 +232,9 @@ void InstancesHider::render_cut() const
clipper->render_cut(); clipper->render_cut();
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
glsafe(::glPopAttrib()); glsafe(::glPopAttrib());
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
++clipper_id; ++clipper_id;
} }
@ -427,18 +427,18 @@ void ObjectClipper::render_cut() const
clipper->set_plane(*m_clp); clipper->set_plane(*m_clp);
clipper->set_transformation(trafo); clipper->set_transformation(trafo);
clipper->set_limiting_plane(ClippingPlane(Vec3d::UnitZ(), -SINKING_Z_THRESHOLD)); clipper->set_limiting_plane(ClippingPlane(Vec3d::UnitZ(), -SINKING_Z_THRESHOLD));
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
clipper->render_cut({ 1.0f, 0.37f, 0.0f, 1.0f }); clipper->render_cut({ 1.0f, 0.37f, 0.0f, 1.0f });
#else #else
glsafe(::glColor3f(1.0f, 0.37f, 0.0f)); glsafe(::glColor3f(1.0f, 0.37f, 0.0f));
clipper->render_cut(); clipper->render_cut();
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
++clipper_id; ++clipper_id;
} }
@ -548,18 +548,18 @@ void SupportsClipper::render_cut() const
m_clipper->set_plane(*ocl->get_clipping_plane()); m_clipper->set_plane(*ocl->get_clipping_plane());
m_clipper->set_transformation(supports_trafo); m_clipper->set_transformation(supports_trafo);
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
m_clipper->render_cut({ 1.0f, 0.f, 0.37f, 1.0f }); m_clipper->render_cut({ 1.0f, 0.f, 0.37f, 1.0f });
#else #else
glsafe(::glColor3f(1.0f, 0.f, 0.37f)); glsafe(::glColor3f(1.0f, 0.f, 0.37f));
m_clipper->render_cut(); m_clipper->render_cut();
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }

View File

@ -124,7 +124,7 @@ bool GLGizmosManager::init()
return true; return true;
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
bool GLGizmosManager::init_arrow(const std::string& filename) bool GLGizmosManager::init_arrow(const std::string& filename)
{ {
if (m_arrow_texture.get_id() != 0) if (m_arrow_texture.get_id() != 0)
@ -149,7 +149,7 @@ bool GLGizmosManager::init_arrow(const BackgroundTexture::Metadata & arrow_textu
return res; return res;
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void GLGizmosManager::set_overlay_icon_size(float size) void GLGizmosManager::set_overlay_icon_size(float size)
{ {
@ -676,7 +676,7 @@ void GLGizmosManager::update_after_undo_redo(const UndoRedo::Snapshot& snapshot)
dynamic_cast<GLGizmoSlaSupports*>(m_gizmos[SlaSupports].get())->reslice_SLA_supports(true); dynamic_cast<GLGizmoSlaSupports*>(m_gizmos[SlaSupports].get())->reslice_SLA_supports(true);
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLGizmosManager::render_background(float left, float top, float right, float bottom, float border_w, float border_h) const void GLGizmosManager::render_background(float left, float top, float right, float bottom, float border_w, float border_h) const
{ {
const unsigned int tex_id = m_background_texture.texture.get_id(); const unsigned int tex_id = m_background_texture.texture.get_id();
@ -782,9 +782,9 @@ void GLGizmosManager::render_background(float left, float top, float right, floa
GLTexture::render_sub_texture(tex_id, internal_right, right, bottom, internal_bottom, { { internal_right_uv, bottom_uv }, { right_uv, bottom_uv }, { right_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv } }); GLTexture::render_sub_texture(tex_id, internal_right, right, bottom, internal_bottom, { { internal_right_uv, bottom_uv }, { right_uv, bottom_uv }, { right_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv } });
} }
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLGizmosManager::render_arrow(const GLCanvas3D& parent, EType highlighted_type) const void GLGizmosManager::render_arrow(const GLCanvas3D& parent, EType highlighted_type) const
{ {
const std::vector<size_t> selectable_idxs = get_selectable_idxs(); const std::vector<size_t> selectable_idxs = get_selectable_idxs();
@ -870,9 +870,9 @@ void GLGizmosManager::render_arrow(const GLCanvas3D& parent, EType highlighted_t
zoomed_top_y -= zoomed_stride_y; zoomed_top_y -= zoomed_stride_y;
} }
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void GLGizmosManager::do_render_overlay() const void GLGizmosManager::do_render_overlay() const
{ {
const std::vector<size_t> selectable_idxs = get_selectable_idxs(); const std::vector<size_t> selectable_idxs = get_selectable_idxs();
@ -1017,7 +1017,7 @@ void GLGizmosManager::do_render_overlay() const
m_gizmos[m_current]->render_input_window(width, current_y, toolbar_top); m_gizmos[m_current]->render_input_window(width, current_y, toolbar_top);
} }
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
float GLGizmosManager::get_scaled_total_height() const float GLGizmosManager::get_scaled_total_height() const
{ {

View File

@ -105,11 +105,11 @@ private:
GLTexture m_icons_texture; GLTexture m_icons_texture;
bool m_icons_texture_dirty; bool m_icons_texture_dirty;
BackgroundTexture m_background_texture; BackgroundTexture m_background_texture;
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLTexture m_arrow_texture; GLTexture m_arrow_texture;
#else #else
BackgroundTexture m_arrow_texture; BackgroundTexture m_arrow_texture;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
Layout m_layout; Layout m_layout;
EType m_current; EType m_current;
EType m_hover; EType m_hover;
@ -137,11 +137,11 @@ public:
bool init(); bool init();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
bool init_arrow(const std::string& filename); bool init_arrow(const std::string& filename);
#else #else
bool init_arrow(const BackgroundTexture::Metadata& arrow_texture); bool init_arrow(const BackgroundTexture::Metadata& arrow_texture);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
template<class Archive> template<class Archive>
void load(Archive& ar) void load(Archive& ar)
@ -242,11 +242,11 @@ private:
bool alt_down = false, bool alt_down = false,
bool control_down = false); bool control_down = false);
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void render_background(float left, float top, float right, float bottom, float border_w, float border_h) const; void render_background(float left, float top, float right, float bottom, float border_w, float border_h) const;
#else #else
void render_background(float left, float top, float right, float bottom, float border) const; void render_background(float left, float top, float right, float bottom, float border) const;
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
void do_render_overlay() const; void do_render_overlay() const;

View File

@ -10,9 +10,9 @@
#include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/GUI_App.hpp"
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#include "slic3r/GUI/Camera.hpp" #include "slic3r/GUI/Camera.hpp"
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
#include "slic3r/GUI/Plater.hpp" #include "slic3r/GUI/Plater.hpp"
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#include <GL/glew.h> #include <GL/glew.h>
@ -87,18 +87,18 @@ void MeshClipper::render_cut()
if (curr_shader != nullptr) if (curr_shader != nullptr)
curr_shader->stop_using(); curr_shader->stop_using();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader != nullptr) { if (shader != nullptr) {
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_model.set_color(color); m_model.set_color(color);
m_model.render(); m_model.render();
shader->stop_using(); shader->stop_using();

View File

@ -1275,11 +1275,11 @@ void Selection::render_center(bool gizmo_is_dragging)
return; return;
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -1290,7 +1290,7 @@ void Selection::render_center(bool gizmo_is_dragging)
glsafe(::glDisable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
Transform3d view_model_matrix = camera.get_view_matrix() * Geometry::assemble_transform(center); Transform3d view_model_matrix = camera.get_view_matrix() * Geometry::assemble_transform(center);
@ -1299,7 +1299,7 @@ void Selection::render_center(bool gizmo_is_dragging)
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glTranslated(center.x(), center.y(), center.z())); glsafe(::glTranslated(center.x(), center.y(), center.z()));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
m_vbo_sphere.set_color(ColorRGBA::WHITE()); m_vbo_sphere.set_color(ColorRGBA::WHITE());
@ -1308,9 +1308,9 @@ void Selection::render_center(bool gizmo_is_dragging)
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
m_vbo_sphere.render(); m_vbo_sphere.render();
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
shader->stop_using(); shader->stop_using();
@ -1324,11 +1324,11 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
return; return;
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader(boost::starts_with(sidebar_field, "layer") ? "flat_attr" : "gouraud_light_attr"); GLShaderProgram* shader = wxGetApp().get_shader(boost::starts_with(sidebar_field, "layer") ? "flat_attr" : "gouraud_light_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader(boost::starts_with(sidebar_field, "layer") ? "flat" : "gouraud_light"); GLShaderProgram* shader = wxGetApp().get_shader(boost::starts_with(sidebar_field, "layer") ? "flat" : "gouraud_light");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -1348,27 +1348,27 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d base_matrix = Geometry::assemble_transform(get_bounding_box().center()); const Transform3d base_matrix = Geometry::assemble_transform(get_bounding_box().center());
Transform3d orient_matrix = Transform3d::Identity(); Transform3d orient_matrix = Transform3d::Identity();
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (!boost::starts_with(sidebar_field, "layer")) { if (!boost::starts_with(sidebar_field, "layer")) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
shader->set_uniform("emission_factor", 0.05f); shader->set_uniform("emission_factor", 0.05f);
#else #else
const Vec3d& center = get_bounding_box().center(); const Vec3d& center = get_bounding_box().center();
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (is_single_full_instance() && !wxGetApp().obj_manipul()->get_world_coordinates()) { if (is_single_full_instance() && !wxGetApp().obj_manipul()->get_world_coordinates()) {
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glTranslated(center.x(), center.y(), center.z())); glsafe(::glTranslated(center.x(), center.y(), center.z()));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
if (!boost::starts_with(sidebar_field, "position")) { if (!boost::starts_with(sidebar_field, "position")) {
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
Transform3d orient_matrix = Transform3d::Identity(); Transform3d orient_matrix = Transform3d::Identity();
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
if (boost::starts_with(sidebar_field, "scale")) if (boost::starts_with(sidebar_field, "scale"))
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); 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")) {
@ -1382,27 +1382,27 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
orient_matrix.rotate(Eigen::AngleAxisd(rotation.z(), Vec3d::UnitZ())); orient_matrix.rotate(Eigen::AngleAxisd(rotation.z(), Vec3d::UnitZ()));
} }
} }
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glMultMatrixd(orient_matrix.data())); glsafe(::glMultMatrixd(orient_matrix.data()));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
} }
else if (is_single_volume() || is_single_modifier()) { else if (is_single_volume() || is_single_modifier()) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
#else #else
glsafe(::glTranslated(center.x(), center.y(), center.z())); glsafe(::glTranslated(center.x(), center.y(), center.z()));
Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (!boost::starts_with(sidebar_field, "position")) 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); orient_matrix = orient_matrix * (*m_volumes)[*m_list.begin()]->get_volume_transformation().get_matrix(true, false, true, true);
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glMultMatrixd(orient_matrix.data())); glsafe(::glMultMatrixd(orient_matrix.data()));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
} }
else { else {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (requires_local_axes()) if (requires_local_axes())
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
#else #else
@ -1411,7 +1411,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
const Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true); const Transform3d orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
glsafe(::glMultMatrixd(orient_matrix.data())); glsafe(::glMultMatrixd(orient_matrix.data()));
} }
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
} }
@ -1420,7 +1420,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
glsafe(::glClear(GL_DEPTH_BUFFER_BIT)); glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
if (boost::starts_with(sidebar_field, "position")) if (boost::starts_with(sidebar_field, "position"))
render_sidebar_position_hints(sidebar_field, *shader, base_matrix * orient_matrix); render_sidebar_position_hints(sidebar_field, *shader, base_matrix * orient_matrix);
else if (boost::starts_with(sidebar_field, "rotation")) else if (boost::starts_with(sidebar_field, "rotation"))
@ -1440,7 +1440,7 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
render_sidebar_layers_hints(sidebar_field); render_sidebar_layers_hints(sidebar_field);
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if !ENABLE_LEGACY_OPENGL_REMOVAL #if !ENABLE_LEGACY_OPENGL_REMOVAL
if (!boost::starts_with(sidebar_field, "layer")) if (!boost::starts_with(sidebar_field, "layer"))
@ -2020,20 +2020,20 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con
glsafe(::glLineWidth(2.0f * m_scale_factor)); glsafe(::glLineWidth(2.0f * m_scale_factor));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr"); GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else #else
GLShaderProgram* shader = wxGetApp().get_shader("flat"); GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr) if (shader == nullptr)
return; return;
shader->start_using(); shader->start_using();
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_box.set_color(to_rgba(color)); m_box.set_color(to_rgba(color));
m_box.render(); m_box.render();
shader->stop_using(); shader->stop_using();
@ -2081,46 +2081,46 @@ static ColorRGBA get_color(Axis axis)
return AXES_COLOR[axis]; return AXES_COLOR[axis];
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void Selection::render_sidebar_position_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix) void Selection::render_sidebar_position_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix)
#else #else
void Selection::render_sidebar_position_hints(const std::string& sidebar_field) void Selection::render_sidebar_position_hints(const std::string& sidebar_field)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Transform3d view_matrix = camera.get_view_matrix() * matrix; const Transform3d view_matrix = camera.get_view_matrix() * matrix;
shader.set_uniform("projection_matrix", camera.get_projection_matrix()); shader.set_uniform("projection_matrix", camera.get_projection_matrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (boost::ends_with(sidebar_field, "x")) { if (boost::ends_with(sidebar_field, "x")) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d view_model_matrix = view_matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitZ()); const Transform3d view_model_matrix = view_matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitZ());
shader.set_uniform("view_model_matrix", view_model_matrix); shader.set_uniform("view_model_matrix", view_model_matrix);
shader.set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); shader.set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
#else #else
glsafe(::glRotated(-90.0, 0.0, 0.0, 1.0)); glsafe(::glRotated(-90.0, 0.0, 0.0, 1.0));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_arrow.set_color(get_color(X)); m_arrow.set_color(get_color(X));
m_arrow.render(); m_arrow.render();
} }
else if (boost::ends_with(sidebar_field, "y")) { else if (boost::ends_with(sidebar_field, "y")) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
shader.set_uniform("view_model_matrix", view_matrix); shader.set_uniform("view_model_matrix", view_matrix);
shader.set_uniform("normal_matrix", (Matrix3d)view_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); shader.set_uniform("normal_matrix", (Matrix3d)view_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_arrow.set_color(get_color(Y)); m_arrow.set_color(get_color(Y));
m_arrow.render(); m_arrow.render();
} }
else if (boost::ends_with(sidebar_field, "z")) { else if (boost::ends_with(sidebar_field, "z")) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Transform3d view_model_matrix = view_matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitX()); const Transform3d view_model_matrix = view_matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitX());
shader.set_uniform("view_model_matrix", view_model_matrix); shader.set_uniform("view_model_matrix", view_model_matrix);
shader.set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); shader.set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
#else #else
glsafe(::glRotated(90.0, 1.0, 0.0, 0.0)); glsafe(::glRotated(90.0, 1.0, 0.0, 0.0));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_arrow.set_color(get_color(Z)); m_arrow.set_color(get_color(Z));
m_arrow.render(); m_arrow.render();
} }
@ -2142,14 +2142,14 @@ void Selection::render_sidebar_position_hints(const std::string& sidebar_field)
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix) void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix)
#else #else
void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field) void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
auto render_sidebar_rotation_hint = [this](GLShaderProgram& shader, const Transform3d& matrix) { auto render_sidebar_rotation_hint = [this](GLShaderProgram& shader, const Transform3d& matrix) {
Transform3d view_model_matrix = matrix; Transform3d view_model_matrix = matrix;
shader.set_uniform("view_model_matrix", view_model_matrix); shader.set_uniform("view_model_matrix", view_model_matrix);
@ -2170,37 +2170,37 @@ void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field)
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0)); glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
m_curved_arrow.render(); m_curved_arrow.render();
}; };
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (boost::ends_with(sidebar_field, "x")) { if (boost::ends_with(sidebar_field, "x")) {
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glRotated(90.0, 0.0, 1.0, 0.0)); glsafe(::glRotated(90.0, 0.0, 1.0, 0.0));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
m_curved_arrow.set_color(get_color(X)); m_curved_arrow.set_color(get_color(X));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_sidebar_rotation_hint(shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitY())); render_sidebar_rotation_hint(shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitY()));
#else #else
render_sidebar_rotation_hint(); render_sidebar_rotation_hint();
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
else if (boost::ends_with(sidebar_field, "y")) { else if (boost::ends_with(sidebar_field, "y")) {
#if !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if !ENABLE_GL_SHADERS_ATTRIBUTES
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0)); glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
#endif // !ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // !ENABLE_GL_SHADERS_ATTRIBUTES
m_curved_arrow.set_color(get_color(Y)); m_curved_arrow.set_color(get_color(Y));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_sidebar_rotation_hint(shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitX())); render_sidebar_rotation_hint(shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitX()));
#else #else
render_sidebar_rotation_hint(); render_sidebar_rotation_hint();
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
else if (boost::ends_with(sidebar_field, "z")) { else if (boost::ends_with(sidebar_field, "z")) {
m_curved_arrow.set_color(get_color(Z)); m_curved_arrow.set_color(get_color(Z));
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_sidebar_rotation_hint(shader, view_matrix); render_sidebar_rotation_hint(shader, view_matrix);
#else #else
render_sidebar_rotation_hint(); render_sidebar_rotation_hint();
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
#else #else
auto render_sidebar_rotation_hint = [this]() { auto render_sidebar_rotation_hint = [this]() {
@ -2226,26 +2226,26 @@ void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field)
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void Selection::render_sidebar_scale_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix) void Selection::render_sidebar_scale_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix)
#else #else
void Selection::render_sidebar_scale_hints(const std::string& sidebar_field) void Selection::render_sidebar_scale_hints(const std::string& sidebar_field)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
const bool uniform_scale = requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling(); const bool uniform_scale = requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis, GLShaderProgram& shader, const Transform3d& matrix) { auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis, GLShaderProgram& shader, const Transform3d& matrix) {
#else #else
auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis) { auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis) {
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if ENABLE_LEGACY_OPENGL_REMOVAL #if ENABLE_LEGACY_OPENGL_REMOVAL
m_arrow.set_color(uniform_scale ? UNIFORM_SCALE_COLOR : get_color(axis)); m_arrow.set_color(uniform_scale ? UNIFORM_SCALE_COLOR : get_color(axis));
#else #else
m_arrow.set_color(-1, uniform_scale ? UNIFORM_SCALE_COLOR : get_color(axis)); m_arrow.set_color(-1, uniform_scale ? UNIFORM_SCALE_COLOR : get_color(axis));
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
Transform3d view_model_matrix = matrix * Geometry::assemble_transform(5.0 * Vec3d::UnitY()); Transform3d view_model_matrix = matrix * Geometry::assemble_transform(5.0 * Vec3d::UnitY());
shader.set_uniform("view_model_matrix", view_model_matrix); shader.set_uniform("view_model_matrix", view_model_matrix);
shader.set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); shader.set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
@ -2255,64 +2255,64 @@ void Selection::render_sidebar_scale_hints(const std::string& sidebar_field)
shader->set_uniform("emission_factor", 0.0f); shader->set_uniform("emission_factor", 0.0f);
glsafe(::glTranslated(0.0, 5.0, 0.0)); glsafe(::glTranslated(0.0, 5.0, 0.0));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_arrow.render(); m_arrow.render();
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
view_model_matrix = matrix * Geometry::assemble_transform(-5.0 * Vec3d::UnitY(), PI * Vec3d::UnitZ()); view_model_matrix = matrix * Geometry::assemble_transform(-5.0 * Vec3d::UnitY(), PI * Vec3d::UnitZ());
shader.set_uniform("view_model_matrix", view_model_matrix); shader.set_uniform("view_model_matrix", view_model_matrix);
shader.set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose()); shader.set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
#else #else
glsafe(::glTranslated(0.0, -10.0, 0.0)); glsafe(::glTranslated(0.0, -10.0, 0.0));
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0)); glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_arrow.render(); m_arrow.render();
}; };
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
const Transform3d view_matrix = camera.get_view_matrix() * matrix; const Transform3d view_matrix = camera.get_view_matrix() * matrix;
shader.set_uniform("projection_matrix", camera.get_projection_matrix()); shader.set_uniform("projection_matrix", camera.get_projection_matrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (boost::ends_with(sidebar_field, "x") || uniform_scale) { if (boost::ends_with(sidebar_field, "x") || uniform_scale) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_sidebar_scale_hint(X, shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitZ())); render_sidebar_scale_hint(X, shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitZ()));
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glRotated(-90.0, 0.0, 0.0, 1.0)); glsafe(::glRotated(-90.0, 0.0, 0.0, 1.0));
render_sidebar_scale_hint(X); render_sidebar_scale_hint(X);
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
if (boost::ends_with(sidebar_field, "y") || uniform_scale) { if (boost::ends_with(sidebar_field, "y") || uniform_scale) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_sidebar_scale_hint(Y, shader, view_matrix); render_sidebar_scale_hint(Y, shader, view_matrix);
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
render_sidebar_scale_hint(Y); render_sidebar_scale_hint(Y);
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
if (boost::ends_with(sidebar_field, "z") || uniform_scale) { if (boost::ends_with(sidebar_field, "z") || uniform_scale) {
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
render_sidebar_scale_hint(Z, shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitX())); render_sidebar_scale_hint(Z, shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitX()));
#else #else
glsafe(::glPushMatrix()); glsafe(::glPushMatrix());
glsafe(::glRotated(90.0, 1.0, 0.0, 0.0)); glsafe(::glRotated(90.0, 1.0, 0.0, 0.0));
render_sidebar_scale_hint(Z); render_sidebar_scale_hint(Z);
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
} }
} }
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void Selection::render_sidebar_layers_hints(const std::string& sidebar_field, GLShaderProgram& shader) void Selection::render_sidebar_layers_hints(const std::string& sidebar_field, GLShaderProgram& shader)
#else #else
void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) void Selection::render_sidebar_layers_hints(const std::string& sidebar_field)
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
{ {
static const float Margin = 10.0f; static const float Margin = 10.0f;
@ -2410,11 +2410,11 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field)
m_planes.models[1].init_from(std::move(init_data)); m_planes.models[1].init_from(std::move(init_data));
} }
#if ENABLE_GLBEGIN_GLEND_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());
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_planes.models[0].set_color((camera_on_top && type == 1) || (!camera_on_top && type == 2) ? SOLID_PLANE_COLOR : TRANSPARENT_PLANE_COLOR); m_planes.models[0].set_color((camera_on_top && type == 1) || (!camera_on_top && type == 2) ? SOLID_PLANE_COLOR : TRANSPARENT_PLANE_COLOR);
m_planes.models[0].render(); m_planes.models[0].render();

View File

@ -376,7 +376,7 @@ private:
void render_selected_volumes() const; void render_selected_volumes() const;
void render_bounding_box(const BoundingBoxf3& box, float* color) const; void render_bounding_box(const BoundingBoxf3& box, float* color) const;
#endif // ENABLE_LEGACY_OPENGL_REMOVAL #endif // ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #if ENABLE_GL_SHADERS_ATTRIBUTES
void render_sidebar_position_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix); void render_sidebar_position_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix);
void render_sidebar_rotation_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix); void render_sidebar_rotation_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix);
void render_sidebar_scale_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix); void render_sidebar_scale_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix);
@ -386,7 +386,7 @@ private:
void render_sidebar_rotation_hints(const std::string& sidebar_field); void render_sidebar_rotation_hints(const std::string& sidebar_field);
void render_sidebar_scale_hints(const std::string& sidebar_field); void render_sidebar_scale_hints(const std::string& sidebar_field);
void render_sidebar_layers_hints(const std::string& sidebar_field); void render_sidebar_layers_hints(const std::string& sidebar_field);
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES #endif // ENABLE_GL_SHADERS_ATTRIBUTES
public: public:
enum SyncRotationType { enum SyncRotationType {