Tech ENABLE_GL_SHADERS_ATTRIBUTES merged into ENABLE_LEGACY_OPENGL_REMOVAL
Fixed conflicts during rebase with master
This commit is contained in:
parent
eb9af502c8
commit
1a1cf108fc
38 changed files with 564 additions and 864 deletions
|
@ -55,12 +55,10 @@
|
|||
#define ENABLE_WIPETOWER_OBJECTID_1000_REMOVAL (1 && ENABLE_2_5_0_ALPHA1)
|
||||
// Enable removal of legacy OpenGL calls
|
||||
#define ENABLE_LEGACY_OPENGL_REMOVAL (1 && ENABLE_2_5_0_ALPHA1)
|
||||
// Enable using vertex attributes and matrices in shaders
|
||||
#define ENABLE_GL_SHADERS_ATTRIBUTES (1 && ENABLE_LEGACY_OPENGL_REMOVAL)
|
||||
// Enable rendering imgui using shaders
|
||||
#define ENABLE_GL_IMGUI_SHADERS (1 && ENABLE_GL_SHADERS_ATTRIBUTES)
|
||||
#define ENABLE_GL_IMGUI_SHADERS (1 && ENABLE_LEGACY_OPENGL_REMOVAL)
|
||||
// Enable OpenGL core profile context
|
||||
#define ENABLE_GL_CORE_PROFILE (1 && ENABLE_GL_SHADERS_ATTRIBUTES)
|
||||
#define ENABLE_GL_CORE_PROFILE (1 && ENABLE_LEGACY_OPENGL_REMOVAL)
|
||||
// Shows an imgui dialog with GLModel statistics data
|
||||
#define ENABLE_GLMODEL_STATISTICS (0 && ENABLE_LEGACY_OPENGL_REMOVAL)
|
||||
// Enable show non-manifold edges
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
#include "GUI_App.hpp"
|
||||
#include "GLCanvas3D.hpp"
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#include "Plater.hpp"
|
||||
#include "Camera.hpp"
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
|
@ -109,7 +109,7 @@ const float Bed3D::Axes::DefaultTipLength = 5.0f;
|
|||
|
||||
void Bed3D::Axes::render()
|
||||
{
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
auto render_axis = [this](GLShaderProgram* shader, const Transform3d& transform) {
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Transform3d matrix = camera.get_view_matrix() * transform;
|
||||
|
@ -120,11 +120,11 @@ void Bed3D::Axes::render()
|
|||
auto render_axis = [this](const Transform3f& transform) {
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glMultMatrixf(transform.data()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_arrow.render();
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
};
|
||||
|
||||
if (!m_arrow.is_initialized())
|
||||
|
@ -142,38 +142,29 @@ void Bed3D::Axes::render()
|
|||
// x axis
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_arrow.set_color(ColorRGBA::X());
|
||||
#else
|
||||
m_arrow.set_color(-1, ColorRGBA::X());
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_axis(shader, Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0 }));
|
||||
#else
|
||||
m_arrow.set_color(-1, ColorRGBA::X());
|
||||
render_axis(Geometry::assemble_transform(m_origin, { 0.0, 0.5 * M_PI, 0.0 }).cast<float>());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// y axis
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_arrow.set_color(ColorRGBA::Y());
|
||||
#else
|
||||
m_arrow.set_color(-1, ColorRGBA::Y());
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_axis(shader, Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0 }));
|
||||
#else
|
||||
m_arrow.set_color(-1, ColorRGBA::Y());
|
||||
render_axis(Geometry::assemble_transform(m_origin, { -0.5 * M_PI, 0.0, 0.0 }).cast<float>());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// z axis
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_arrow.set_color(ColorRGBA::Z());
|
||||
#else
|
||||
m_arrow.set_color(-1, ColorRGBA::Z());
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_axis(shader, Geometry::assemble_transform(m_origin));
|
||||
#else
|
||||
m_arrow.set_color(-1, ColorRGBA::Z());
|
||||
render_axis(Geometry::assemble_transform(m_origin).cast<float>());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
shader->stop_using();
|
||||
|
||||
|
@ -269,7 +260,7 @@ Point Bed3D::point_projection(const Point& point) const
|
|||
return m_polygon.point_projection(point);
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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);
|
||||
|
@ -289,15 +280,15 @@ void Bed3D::render_for_picking(GLCanvas3D& canvas, bool bottom, float scale_fact
|
|||
{
|
||||
render_internal(canvas, bottom, scale_factor, false, false, true);
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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)
|
||||
#else
|
||||
void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
|
||||
bool show_axes, bool show_texture, bool picking)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
m_scale_factor = scale_factor;
|
||||
|
||||
|
@ -314,7 +305,7 @@ void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
|
|||
|
||||
switch (m_type)
|
||||
{
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
case Type::System: { render_system(canvas, view_matrix, projection_matrix, bottom, show_texture); break; }
|
||||
default:
|
||||
case Type::Custom: { render_custom(canvas, view_matrix, projection_matrix, bottom, show_texture, picking); break; }
|
||||
|
@ -322,7 +313,7 @@ void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
|
|||
case Type::System: { render_system(canvas, bottom, show_texture); break; }
|
||||
default:
|
||||
case Type::Custom: { render_custom(canvas, bottom, show_texture, picking); break; }
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
@ -542,7 +533,7 @@ void Bed3D::render_axes()
|
|||
m_axes.render();
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void Bed3D::render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture)
|
||||
{
|
||||
if (!bottom)
|
||||
|
@ -564,21 +555,21 @@ void Bed3D::render_system(GLCanvas3D& canvas, bool bottom, bool show_texture)
|
|||
else if (bottom)
|
||||
render_contour();
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix)
|
||||
#else
|
||||
void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
if (m_texture_filename.empty()) {
|
||||
m_texture.reset();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
render_default(bottom, false, true, view_matrix, projection_matrix);
|
||||
#else
|
||||
render_default(bottom, false, true);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -591,11 +582,11 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
|
|||
if (m_temp_texture.get_id() == 0 || m_temp_texture.get_source() != m_texture_filename) {
|
||||
// generate a temporary lower resolution texture to show while no main texture levels have been compressed
|
||||
if (!m_temp_texture.load_from_svg_file(m_texture_filename, false, false, false, max_tex_size / 8)) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
render_default(bottom, false, true, view_matrix, projection_matrix);
|
||||
#else
|
||||
render_default(bottom, false, true);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
return;
|
||||
}
|
||||
canvas.request_extra_frame();
|
||||
|
@ -603,11 +594,11 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
|
|||
|
||||
// starts generating the main texture, compression will run asynchronously
|
||||
if (!m_texture.load_from_svg_file(m_texture_filename, true, true, true, max_tex_size)) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
render_default(bottom, false, true, view_matrix, projection_matrix);
|
||||
#else
|
||||
render_default(bottom, false, true);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -615,11 +606,11 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
|
|||
// generate a temporary lower resolution texture to show while no main texture levels have been compressed
|
||||
if (m_temp_texture.get_id() == 0 || m_temp_texture.get_source() != m_texture_filename) {
|
||||
if (!m_temp_texture.load_from_file(m_texture_filename, false, GLTexture::None, false)) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
render_default(bottom, false, true, view_matrix, projection_matrix);
|
||||
#else
|
||||
render_default(bottom, false, true);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
return;
|
||||
}
|
||||
canvas.request_extra_frame();
|
||||
|
@ -627,20 +618,20 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
|
|||
|
||||
// starts generating the main texture, compression will run asynchronously
|
||||
if (!m_texture.load_from_file(m_texture_filename, true, GLTexture::MultiThreaded, true)) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
render_default(bottom, false, true, view_matrix, projection_matrix);
|
||||
#else
|
||||
render_default(bottom, false, true);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
render_default(bottom, false, true, view_matrix, projection_matrix);
|
||||
#else
|
||||
render_default(bottom, false, true);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -661,10 +652,8 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
|
|||
GLShaderProgram* shader = wxGetApp().get_shader("printbed");
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
shader->set_uniform("view_model_matrix", view_matrix);
|
||||
shader->set_uniform("projection_matrix", projection_matrix);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
shader->set_uniform("transparent_background", bottom);
|
||||
shader->set_uniform("svg_source", boost::algorithm::iends_with(m_texture.get_source(), ".svg"));
|
||||
|
||||
|
@ -758,11 +747,11 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
|
|||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void Bed3D::render_model(const Transform3d& view_matrix, const Transform3d& projection_matrix)
|
||||
#else
|
||||
void Bed3D::render_model()
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
if (m_model_filename.empty())
|
||||
return;
|
||||
|
@ -786,7 +775,7 @@ void Bed3D::render_model()
|
|||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
shader->set_uniform("emission_factor", 0.0f);
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Transform3d matrix = view_matrix * Geometry::assemble_transform(m_model_offset);
|
||||
shader->set_uniform("view_model_matrix", matrix);
|
||||
shader->set_uniform("projection_matrix", projection_matrix);
|
||||
|
@ -794,55 +783,55 @@ void Bed3D::render_model()
|
|||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(m_model_offset.x(), m_model_offset.y(), m_model_offset.z()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_model.render();
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->stop_using();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void Bed3D::render_custom(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture, bool picking)
|
||||
#else
|
||||
void Bed3D::render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
if (m_texture_filename.empty() && m_model_filename.empty()) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
render_default(bottom, picking, show_texture, view_matrix, projection_matrix);
|
||||
#else
|
||||
render_default(bottom, picking, show_texture);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
return;
|
||||
}
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (!bottom)
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_model(view_matrix, projection_matrix);
|
||||
#else
|
||||
render_model();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
if (show_texture)
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_texture(bottom, canvas, view_matrix, projection_matrix);
|
||||
else if (bottom)
|
||||
render_contour(view_matrix, projection_matrix);
|
||||
#else
|
||||
if (!bottom)
|
||||
render_model();
|
||||
|
||||
if (show_texture)
|
||||
render_texture(bottom, canvas);
|
||||
else if (bottom)
|
||||
render_contour();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void Bed3D::render_default(bool bottom, bool picking, bool show_texture, const Transform3d& view_matrix, const Transform3d& projection_matrix)
|
||||
#else
|
||||
void Bed3D::render_default(bool bottom, bool picking, bool show_texture)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
m_texture.reset();
|
||||
|
||||
|
@ -854,10 +843,8 @@ void Bed3D::render_default(bool bottom, bool picking, bool show_texture)
|
|||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
shader->set_uniform("view_model_matrix", view_matrix);
|
||||
shader->set_uniform("projection_matrix", projection_matrix);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
glsafe(::glEnable(GL_BLEND));
|
||||
|
|
|
@ -141,13 +141,13 @@ public:
|
|||
bool contains(const Point& point) const;
|
||||
Point point_projection(const Point& point) const;
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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);
|
||||
#else
|
||||
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);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
private:
|
||||
// Calculate an extended bounding box from axes and current model for visualization purposes.
|
||||
|
@ -162,15 +162,15 @@ private:
|
|||
void calc_contourlines(const ExPolygon& poly);
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
static std::tuple<Type, std::string, std::string> detect_type(const Pointfs& shape);
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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);
|
||||
#else
|
||||
void render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
|
||||
bool show_axes, bool show_texture, bool picking);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void render_axes();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture);
|
||||
void render_texture(bool bottom, GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix);
|
||||
void render_model(const Transform3d& view_matrix, const Transform3d& projection_matrix);
|
||||
|
@ -184,11 +184,9 @@ private:
|
|||
void render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking);
|
||||
void render_default(bool bottom, bool picking, bool show_texture);
|
||||
void render_contour();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void release_VBOs();
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
};
|
||||
|
||||
} // GUI
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include "GUI_App.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "BitmapCache.hpp"
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#include "Camera.hpp"
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#include "libslic3r/BuildVolume.hpp"
|
||||
#include "libslic3r/ExtrusionEntity.hpp"
|
||||
|
@ -301,7 +301,7 @@ void GLVolume::SinkingContours::render()
|
|||
{
|
||||
update();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
|
@ -312,11 +312,11 @@ void GLVolume::SinkingContours::render()
|
|||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(m_shift.x(), m_shift.y(), m_shift.z()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_model.render();
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
void GLVolume::SinkingContours::update()
|
||||
|
@ -392,7 +392,7 @@ void GLVolume::NonManifoldEdges::render()
|
|||
#if !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glLineWidth(2.0f));
|
||||
#endif // !ENABLE_GL_CORE_PROFILE
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
|
@ -406,19 +406,16 @@ void GLVolume::NonManifoldEdges::render()
|
|||
shader->set_uniform("width", 0.5f);
|
||||
shader->set_uniform("gap_size", 0.0f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
m_model.set_color(complementary(m_parent.render_color));
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glMultMatrixd(m_parent.world_matrix().data()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_model.set_color(complementary(m_parent.render_color));
|
||||
#else
|
||||
m_model.set_color(-1, complementary(m_parent.render_color));
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_model.render();
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
void GLVolume::NonManifoldEdges::update()
|
||||
|
@ -710,19 +707,15 @@ void GLVolume::render()
|
|||
if (!is_active)
|
||||
return;
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
GLShaderProgram* shader = GUI::wxGetApp().get_current_shader();
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
if (this->is_left_handed())
|
||||
glFrontFace(GL_CW);
|
||||
glsafe(::glFrontFace(GL_CW));
|
||||
glsafe(::glCullFace(GL_BACK));
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glMultMatrixd(world_matrix().data()));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (tverts_range == std::make_pair<size_t, size_t>(0, -1))
|
||||
|
@ -730,15 +723,14 @@ void GLVolume::render()
|
|||
else
|
||||
model.render(this->tverts_range);
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glMultMatrixd(world_matrix().data()));
|
||||
this->indexed_vertex_array.render(this->tverts_range, this->qverts_range);
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
if (this->is_left_handed())
|
||||
glFrontFace(GL_CCW);
|
||||
glsafe(::glFrontFace(GL_CCW));
|
||||
}
|
||||
|
||||
bool GLVolume::is_sla_support() const { return this->composite_id.volume_id == -int(slaposSupportTree); }
|
||||
|
@ -1077,12 +1069,12 @@ GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCo
|
|||
return list;
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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
|
||||
#else
|
||||
void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disable_cullface, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func) const
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
GLVolumeWithIdAndZList to_render = volumes_to_render(volumes, type, view_matrix, filter_func);
|
||||
if (to_render.empty())
|
||||
|
@ -1135,13 +1127,11 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||
sink_shader->stop_using();
|
||||
}
|
||||
shader->start_using();
|
||||
#else
|
||||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
shader->set_uniform("z_range", m_z_range);
|
||||
shader->set_uniform("clipping_plane", m_clipping_plane);
|
||||
shader->set_uniform("print_volume.type", static_cast<int>(m_print_volume.type));
|
||||
|
@ -1163,15 +1153,13 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
volume.first->model.set_color(volume.first->render_color);
|
||||
#else
|
||||
shader->set_uniform("uniform_color", volume.first->render_color);
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Transform3d matrix = view_matrix * volume.first->world_matrix();
|
||||
shader->set_uniform("view_model_matrix", matrix);
|
||||
shader->set_uniform("projection_matrix", projection_matrix);
|
||||
shader->set_uniform("normal_matrix", (Matrix3d)matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#else
|
||||
shader->set_uniform("uniform_color", volume.first->render_color);
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
volume.first->render();
|
||||
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
|
@ -1182,10 +1170,10 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
|
|||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
if (m_show_sinking_contours) {
|
||||
|
|
|
@ -681,28 +681,23 @@ public:
|
|||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
GLVolume* new_toolpath_volume(const ColorRGBA& rgba);
|
||||
GLVolume* new_nontoolpath_volume(const ColorRGBA& rgba);
|
||||
#else
|
||||
GLVolume* new_toolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0);
|
||||
GLVolume* new_nontoolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0);
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// Render the volumes by OpenGL.
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
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;
|
||||
#else
|
||||
GLVolume* new_toolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0);
|
||||
GLVolume* new_nontoolpath_volume(const ColorRGBA& rgba, size_t reserve_vbo_floats = 0);
|
||||
// Render the volumes by OpenGL.
|
||||
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_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
// Finalize the initialization of the geometry & indices,
|
||||
// upload the geometry and indices to OpenGL VBO objects
|
||||
// and shrink the allocated data, possibly relasing it if it has been loaded into the VBOs.
|
||||
void finalize_geometry(bool opengl_initialized) { for (auto* v : volumes) v->finalize_geometry(opengl_initialized); }
|
||||
// Release the geometry data assigned to the volumes.
|
||||
// If OpenGL VBOs were allocated, an OpenGL context has to be active to release them.
|
||||
void release_geometry() { for (auto *v : volumes) v->release_geometry(); }
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void release_geometry() { for (auto* v : volumes) v->release_geometry(); }
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// Clear the geometry
|
||||
void clear() { for (auto *v : volumes) delete v; volumes.clear(); }
|
||||
|
||||
|
|
|
@ -200,11 +200,11 @@ void GCodeViewer::COG::render()
|
|||
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
Transform3d matrix = camera.get_view_matrix() * Geometry::assemble_transform(cog());
|
||||
if (m_fixed_size) {
|
||||
const double inv_zoom = wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||
const double inv_zoom = camera.get_inv_zoom();
|
||||
matrix = matrix * Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), inv_zoom * Vec3d::Ones());
|
||||
}
|
||||
shader->set_uniform("view_model_matrix", matrix);
|
||||
|
@ -221,7 +221,7 @@ void GCodeViewer::COG::render()
|
|||
}
|
||||
m_model.render();
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
shader->stop_using();
|
||||
|
||||
|
@ -347,7 +347,7 @@ void GCodeViewer::SequentialView::Marker::render()
|
|||
|
||||
shader->start_using();
|
||||
shader->set_uniform("emission_factor", 0.0f);
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Transform3d matrix = camera.get_view_matrix() * m_world_transform.cast<double>();
|
||||
shader->set_uniform("view_model_matrix", matrix);
|
||||
|
@ -356,13 +356,13 @@ void GCodeViewer::SequentialView::Marker::render()
|
|||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glMultMatrixf(m_world_transform.data()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
m_model.render();
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
shader->stop_using();
|
||||
|
||||
|
@ -733,7 +733,7 @@ void GCodeViewer::init()
|
|||
}
|
||||
case EMoveType::Travel: {
|
||||
buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Line;
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
buffer.vertices.format = VBuffer::EFormat::Position;
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
buffer.shader = "dashed_thick_lines";
|
||||
|
@ -743,7 +743,7 @@ void GCodeViewer::init()
|
|||
#else
|
||||
buffer.vertices.format = VBuffer::EFormat::PositionNormal3;
|
||||
buffer.shader = "toolpaths_lines";
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1315,21 +1315,19 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
|||
|
||||
// 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) {
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
// 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();
|
||||
Vec3f normal(dir.y(), -dir.x(), 0.0);
|
||||
normal.normalize();
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
auto add_vertex = [&vertices](const GCodeProcessorResult::MoveVertex& vertex) {
|
||||
// add position
|
||||
vertices.push_back(vertex.position.x());
|
||||
vertices.push_back(vertex.position.y());
|
||||
vertices.push_back(vertex.position.z());
|
||||
};
|
||||
};
|
||||
#else
|
||||
// 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();
|
||||
Vec3f normal(dir.y(), -dir.x(), 0.0);
|
||||
normal.normalize();
|
||||
|
||||
auto add_vertex = [&vertices, &normal](const GCodeProcessorResult::MoveVertex& vertex) {
|
||||
// add position
|
||||
vertices.push_back(vertex.position.x());
|
||||
|
@ -1340,7 +1338,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
|||
vertices.push_back(normal.y());
|
||||
vertices.push_back(normal.z());
|
||||
};
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// add previous vertex
|
||||
add_vertex(prev);
|
||||
|
@ -2996,19 +2994,19 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
|||
|
||||
void GCodeViewer::render_toolpaths()
|
||||
{
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const std::array<float, 4> light_intensity = { 0.25f, 0.70f, 0.75f, 0.75f };
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
#if !ENABLE_GL_CORE_PROFILE
|
||||
const double zoom = camera.get_zoom();
|
||||
#endif // !ENABLE_GL_CORE_PROFILE
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
auto shader_init_as_lines = [light_intensity](GLShaderProgram &shader) {
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
auto shader_init_as_lines = [light_intensity](GLShaderProgram &shader) {
|
||||
shader.set_uniform("light_intensity", light_intensity);
|
||||
};
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
auto render_as_lines = [
|
||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||
this
|
||||
|
@ -3082,7 +3080,7 @@ void GCodeViewer::render_toolpaths()
|
|||
}
|
||||
};
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||
auto render_as_batched_model = [this](TBuffer& buffer, GLShaderProgram& shader, int position_id, int normal_id) {
|
||||
#else
|
||||
|
@ -3094,7 +3092,7 @@ void GCodeViewer::render_toolpaths()
|
|||
#else
|
||||
auto render_as_batched_model = [](TBuffer& buffer, GLShaderProgram& shader) {
|
||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
struct Range
|
||||
{
|
||||
|
@ -3112,7 +3110,7 @@ void GCodeViewer::render_toolpaths()
|
|||
glsafe(::glBindVertexArray(i_buffer.vao));
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, i_buffer.vbo));
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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(::glEnableVertexAttribArray(position_id));
|
||||
|
@ -3120,10 +3118,10 @@ void GCodeViewer::render_toolpaths()
|
|||
#else
|
||||
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));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const bool has_normals = buffer.vertices.normal_size_floats() > 0;
|
||||
if (has_normals) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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(::glEnableVertexAttribArray(normal_id));
|
||||
|
@ -3131,7 +3129,7 @@ void GCodeViewer::render_toolpaths()
|
|||
#else
|
||||
glsafe(::glNormalPointer(GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes()));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, i_buffer.ibo));
|
||||
|
@ -3155,7 +3153,7 @@ void GCodeViewer::render_toolpaths()
|
|||
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (normal_id != -1)
|
||||
glsafe(::glDisableVertexAttribArray(normal_id));
|
||||
if (position_id != -1)
|
||||
|
@ -3165,7 +3163,7 @@ void GCodeViewer::render_toolpaths()
|
|||
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
|
||||
|
||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindVertexArray(0));
|
||||
|
@ -3195,12 +3193,12 @@ void GCodeViewer::render_toolpaths()
|
|||
|
||||
shader->start_using();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Transform3d& view_matrix = camera.get_view_matrix();
|
||||
shader->set_uniform("view_model_matrix", view_matrix);
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
shader->set_uniform("normal_matrix", (Matrix3d)view_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::InstancedModel) {
|
||||
shader->set_uniform("emission_factor", 0.25f);
|
||||
|
@ -3209,23 +3207,23 @@ void GCodeViewer::render_toolpaths()
|
|||
}
|
||||
else if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::BatchedModel) {
|
||||
shader->set_uniform("emission_factor", 0.25f);
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const int position_id = shader->get_attrib_location("v_position");
|
||||
const int normal_id = shader->get_attrib_location("v_normal");
|
||||
render_as_batched_model(buffer, *shader, position_id, normal_id);
|
||||
#else
|
||||
render_as_batched_model(buffer, *shader);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->set_uniform("emission_factor", 0.0f);
|
||||
}
|
||||
else {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const int position_id = shader->get_attrib_location("v_position");
|
||||
const int normal_id = shader->get_attrib_location("v_normal");
|
||||
#else
|
||||
if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Line)
|
||||
shader_init_as_lines(*shader);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const int uniform_color = shader->get_uniform_location("uniform_color");
|
||||
|
||||
auto it_path = buffer.render_paths.begin();
|
||||
|
@ -3241,7 +3239,7 @@ void GCodeViewer::render_toolpaths()
|
|||
glsafe(::glBindVertexArray(i_buffer.vao));
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, i_buffer.vbo));
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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(::glEnableVertexAttribArray(position_id));
|
||||
|
@ -3249,10 +3247,10 @@ void GCodeViewer::render_toolpaths()
|
|||
#else
|
||||
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));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const bool has_normals = buffer.vertices.normal_size_floats() > 0;
|
||||
if (has_normals) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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(::glEnableVertexAttribArray(normal_id));
|
||||
|
@ -3260,7 +3258,7 @@ void GCodeViewer::render_toolpaths()
|
|||
#else
|
||||
glsafe(::glNormalPointer(GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes()));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, i_buffer.ibo));
|
||||
|
@ -3284,7 +3282,7 @@ void GCodeViewer::render_toolpaths()
|
|||
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (normal_id != -1)
|
||||
glsafe(::glDisableVertexAttribArray(normal_id));
|
||||
if (position_id != -1)
|
||||
|
@ -3294,7 +3292,7 @@ void GCodeViewer::render_toolpaths()
|
|||
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
|
||||
|
||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindVertexArray(0));
|
||||
|
@ -3318,7 +3316,7 @@ void GCodeViewer::render_toolpaths()
|
|||
|
||||
shader->start_using();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Transform3d& view_matrix = camera.get_view_matrix();
|
||||
shader->set_uniform("view_model_matrix", view_matrix);
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
|
@ -3326,13 +3324,13 @@ void GCodeViewer::render_toolpaths()
|
|||
|
||||
const int position_id = shader->get_attrib_location("v_position");
|
||||
const int normal_id = shader->get_attrib_location("v_normal");
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindVertexArray(cap.vao));
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, cap.vbo));
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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(::glEnableVertexAttribArray(position_id));
|
||||
|
@ -3340,10 +3338,10 @@ void GCodeViewer::render_toolpaths()
|
|||
#else
|
||||
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));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const bool has_normals = buffer->vertices.normal_size_floats() > 0;
|
||||
if (has_normals) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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(::glEnableVertexAttribArray(normal_id));
|
||||
|
@ -3351,7 +3349,7 @@ void GCodeViewer::render_toolpaths()
|
|||
#else
|
||||
glsafe(::glNormalPointer(GL_FLOAT, buffer->vertices.vertex_size_bytes(), (const void*)buffer->vertices.normal_offset_bytes()));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
shader->set_uniform("uniform_color", cap.color);
|
||||
|
@ -3364,7 +3362,7 @@ void GCodeViewer::render_toolpaths()
|
|||
++m_statistics.gl_triangles_calls_count;
|
||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (normal_id != -1)
|
||||
glsafe(::glDisableVertexAttribArray(normal_id));
|
||||
if (position_id != -1)
|
||||
|
@ -3374,7 +3372,7 @@ void GCodeViewer::render_toolpaths()
|
|||
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
|
||||
|
||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
|
@ -3412,12 +3410,12 @@ void GCodeViewer::render_shells()
|
|||
// glsafe(::glDepthMask(GL_FALSE));
|
||||
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
m_shells.volumes.render(GLVolumeCollection::ERenderType::Transparent, true, camera.get_view_matrix(), camera.get_projection_matrix());
|
||||
#else
|
||||
m_shells.volumes.render(GLVolumeCollection::ERenderType::Transparent, true, wxGetApp().plater()->get_camera().get_view_matrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->stop_using();
|
||||
|
||||
// glsafe(::glDepthMask(GL_TRUE));
|
||||
|
|
|
@ -263,21 +263,14 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas)
|
|||
GLCanvas3D::LayersEditing::s_overlay_window_width = ImGui::GetWindowSize().x /*+ (float)m_layers_texture.width/4*/;
|
||||
imgui.end();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
render_active_object_annotations(canvas);
|
||||
render_profile(canvas);
|
||||
#else
|
||||
const Rect& bar_rect = get_bar_rect_viewport(canvas);
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_profile.dirty = m_profile.old_bar_rect != bar_rect;
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
render_active_object_annotations(canvas, bar_rect);
|
||||
render_profile(bar_rect);
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_profile.old_bar_rect = bar_rect;
|
||||
m_profile.dirty = false;
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
|
||||
float GLCanvas3D::LayersEditing::get_cursor_z_relative(const GLCanvas3D& canvas)
|
||||
|
@ -311,7 +304,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_screen(const GLCanvas3D& canvas)
|
|||
return { w - thickness_bar_width(canvas), 0.0f, w, h };
|
||||
}
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
|
||||
{
|
||||
const Size& cnv_size = canvas.get_canvas_size();
|
||||
|
@ -320,7 +313,7 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
|
|||
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 };
|
||||
}
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
bool GLCanvas3D::LayersEditing::is_initialized() const
|
||||
{
|
||||
|
@ -353,21 +346,20 @@ std::string GLCanvas3D::LayersEditing::get_tooltip(const GLCanvas3D& canvas) con
|
|||
return ret;
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3D& canvas)
|
||||
#else
|
||||
void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
{
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
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();
|
||||
if (cnv_width == 0.0f || cnv_height == 0.0f)
|
||||
return;
|
||||
|
||||
const float cnv_inv_width = 1.0f / cnv_width;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#else
|
||||
void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3D & canvas, const Rect & bar_rect)
|
||||
{
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("variable_layer_height");
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
|
@ -379,23 +371,19 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
|||
shader->set_uniform("z_cursor", m_object_max_z * this->get_cursor_z_relative(canvas));
|
||||
shader->set_uniform("z_cursor_band_width", band_width);
|
||||
shader->set_uniform("object_max_z", m_object_max_z);
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
||||
shader->set_uniform("normal_matrix", (Matrix3d)Eigen::Matrix3d::Identity());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
glsafe(::glPixelStorei(GL_UNPACK_ALIGNMENT, 1));
|
||||
glsafe(::glBindTexture(GL_TEXTURE_2D, m_z_texture_id));
|
||||
|
||||
// Render the color bar
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (!m_profile.background.is_initialized() || m_profile.old_canvas_width != cnv_width) {
|
||||
m_profile.old_canvas_width = cnv_width;
|
||||
#else
|
||||
if (!m_profile.background.is_initialized() || m_profile.dirty) {
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_profile.background.reset();
|
||||
|
||||
GLModel::Geometry init_data;
|
||||
|
@ -404,17 +392,10 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
|||
init_data.reserve_indices(6);
|
||||
|
||||
// vertices
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const float l = 1.0f - 2.0f * THICKNESS_BAR_WIDTH * cnv_inv_width;
|
||||
const float r = 1.0f;
|
||||
const float t = 1.0f;
|
||||
const float b = -1.0f;
|
||||
#else
|
||||
const float l = bar_rect.get_left();
|
||||
const float r = bar_rect.get_right();
|
||||
const float t = bar_rect.get_top();
|
||||
const float b = bar_rect.get_bottom();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
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, t), Vec2f(1.0f, 1.0f));
|
||||
|
@ -448,18 +429,18 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
|||
shader->stop_using();
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void GLCanvas3D::LayersEditing::render_profile(const GLCanvas3D& canvas)
|
||||
#else
|
||||
void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
//FIXME show some kind of legend.
|
||||
|
||||
if (!m_slicing_parameters)
|
||||
return;
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Size cnv_size = canvas.get_canvas_size();
|
||||
const float cnv_width = (float)cnv_size.get_width();
|
||||
const float cnv_height = (float)cnv_size.get_height();
|
||||
|
@ -476,15 +457,11 @@ 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.
|
||||
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;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
// Baseline
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (!m_profile.baseline.is_initialized() || m_profile.old_layer_height_profile != m_layer_height_profile) {
|
||||
#else
|
||||
if (!m_profile.baseline.is_initialized() || m_profile.dirty) {
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_profile.baseline.reset();
|
||||
|
||||
GLModel::Geometry init_data;
|
||||
|
@ -494,15 +471,9 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
|
|||
init_data.reserve_indices(2);
|
||||
|
||||
// vertices
|
||||
#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);
|
||||
init_data.add_vertex(Vec2f(axis_x, -1.0f));
|
||||
init_data.add_vertex(Vec2f(axis_x, 1.0f));
|
||||
#else
|
||||
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_top()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
// indices
|
||||
init_data.add_line(0, 1);
|
||||
|
@ -510,11 +481,7 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
|
|||
m_profile.baseline.init_from(std::move(init_data));
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (!m_profile.profile.is_initialized() || m_profile.old_layer_height_profile != m_layer_height_profile) {
|
||||
#else
|
||||
if (!m_profile.profile.is_initialized() || m_profile.dirty || m_profile.old_layer_height_profile != m_layer_height_profile) {
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_profile.old_layer_height_profile = m_layer_height_profile;
|
||||
m_profile.profile.reset();
|
||||
|
||||
|
@ -526,13 +493,8 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
|
|||
|
||||
// vertices + indices
|
||||
for (unsigned int i = 0; i < (unsigned int)m_layer_height_profile.size(); i += 2) {
|
||||
#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),
|
||||
2.0f * (float(m_layer_height_profile[i]) * scale_y * cnv_inv_height - 0.5)));
|
||||
#else
|
||||
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));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
2.0f * (float(m_layer_height_profile[i]) * scale_y * cnv_inv_height - 0.5)));
|
||||
init_data.add_index(i / 2);
|
||||
}
|
||||
|
||||
|
@ -542,10 +504,8 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
|
|||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_profile.baseline.render();
|
||||
m_profile.profile.render();
|
||||
shader->stop_using();
|
||||
|
@ -593,10 +553,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_band_width", float(this->band_width));
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// Initialize the layer height texture mapping.
|
||||
const GLsizei w = (GLsizei)m_layers_texture.width;
|
||||
|
@ -616,11 +576,11 @@ void GLCanvas3D::LayersEditing::render_volumes(const GLCanvas3D& canvas, const G
|
|||
|
||||
shader->set_uniform("volume_world_matrix", glvolume->world_matrix());
|
||||
shader->set_uniform("object_max_z", 0.0f);
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Transform3d view_model_matrix = camera.get_view_matrix() * glvolume->world_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());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
glvolume->render();
|
||||
}
|
||||
|
@ -1065,11 +1025,11 @@ void GLCanvas3D::SequentialPrintClearance::render()
|
|||
|
||||
shader->start_using();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
glsafe(::glDisable(GL_CULL_FACE));
|
||||
|
@ -1705,11 +1665,11 @@ void GLCanvas3D::render()
|
|||
_render_sla_slices();
|
||||
_render_selection();
|
||||
if (is_looking_downward)
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
_render_bed(camera.get_view_matrix(), camera.get_projection_matrix(), false, true);
|
||||
#else
|
||||
_render_bed(false, true);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
_render_objects(GLVolumeCollection::ERenderType::Transparent);
|
||||
|
||||
_render_sequential_clearance();
|
||||
|
@ -1732,11 +1692,11 @@ void GLCanvas3D::render()
|
|||
_render_selection_sidebar_hints();
|
||||
_render_current_gizmo();
|
||||
if (!is_looking_downward)
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
_render_bed(camera.get_view_matrix(), camera.get_projection_matrix(), true, true);
|
||||
#else
|
||||
_render_bed(true, true);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_RENDER_PICKING_PASS
|
||||
}
|
||||
#endif // ENABLE_RENDER_PICKING_PASS
|
||||
|
@ -4337,12 +4297,12 @@ bool GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x)
|
|||
|
||||
ImGuiWrapper* imgui = wxGetApp().imgui();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
imgui->set_next_window_pos(pos_x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
#else
|
||||
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);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
std::string title = is_undo ? L("Undo History") : L("Redo History");
|
||||
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
|
@ -4381,12 +4341,12 @@ bool GLCanvas3D::_render_search_list(float pos_x)
|
|||
bool action_taken = false;
|
||||
ImGuiWrapper* imgui = wxGetApp().imgui();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
imgui->set_next_window_pos(pos_x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
#else
|
||||
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);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
std::string title = L("Search");
|
||||
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
|
@ -4439,13 +4399,13 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
|
|||
{
|
||||
ImGuiWrapper *imgui = wxGetApp().imgui();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
imgui->set_next_window_pos(pos_x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
#else
|
||||
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;
|
||||
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
imgui->begin(_L("Arrange options"), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
|
@ -4568,13 +4528,12 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
camera.set_scene_box(scene_bounding_box());
|
||||
camera.apply_viewport(0, 0, thumbnail_data.width, thumbnail_data.height);
|
||||
camera.zoom_to_box(volumes_box);
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
camera.apply_view_matrix();
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Transform3d& view_matrix = camera.get_view_matrix();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#else
|
||||
camera.apply_view_matrix();
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
double near_z = -1.0;
|
||||
double far_z = -1.0;
|
||||
|
@ -4583,11 +4542,11 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
// extends the near and far z of the frustrum to avoid the bed being clipped
|
||||
|
||||
// box in eye space
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const BoundingBoxf3 t_bed_box = m_bed.extended_bounding_box().transformed(view_matrix);
|
||||
#else
|
||||
const BoundingBoxf3 t_bed_box = m_bed.extended_bounding_box().transformed(camera.get_view_matrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
near_z = -t_bed_box.max.z();
|
||||
far_z = -t_bed_box.min.z();
|
||||
}
|
||||
|
@ -4607,9 +4566,9 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
shader->start_using();
|
||||
shader->set_uniform("emission_factor", 0.0f);
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Transform3d& projection_matrix = camera.get_projection_matrix();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
for (GLVolume* vol : visible_volumes) {
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
@ -4620,12 +4579,12 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
// the volume may have been deactivated by an active gizmo
|
||||
const bool is_active = vol->is_active;
|
||||
vol->is_active = true;
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Transform3d matrix = view_matrix * vol->world_matrix();
|
||||
shader->set_uniform("view_model_matrix", matrix);
|
||||
shader->set_uniform("projection_matrix", projection_matrix);
|
||||
shader->set_uniform("normal_matrix", (Matrix3d)matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
vol->render();
|
||||
vol->is_active = is_active;
|
||||
}
|
||||
|
@ -4635,11 +4594,11 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
if (thumbnail_params.show_bed)
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
_render_bed(view_matrix, projection_matrix, !camera.is_looking_downward(), false);
|
||||
#else
|
||||
_render_bed(!camera.is_looking_downward(), false);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// restore background color
|
||||
if (thumbnail_params.transparent_background)
|
||||
|
@ -4906,7 +4865,7 @@ bool GLCanvas3D::_init_main_toolbar()
|
|||
return true;
|
||||
}
|
||||
// init arrow
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (!m_main_toolbar.init_arrow("toolbar_arrow_2.svg"))
|
||||
#else
|
||||
BackgroundTexture::Metadata arrow_data;
|
||||
|
@ -4916,15 +4875,15 @@ bool GLCanvas3D::_init_main_toolbar()
|
|||
arrow_data.right = 0;
|
||||
arrow_data.bottom = 0;
|
||||
if (!m_main_toolbar.init_arrow(arrow_data))
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
BOOST_LOG_TRIVIAL(error) << "Main toolbar failed to load arrow texture.";
|
||||
|
||||
// m_gizmos is created at constructor, thus we can init arrow here.
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (!m_gizmos.init_arrow("toolbar_arrow_2.svg"))
|
||||
#else
|
||||
if (!m_gizmos.init_arrow(arrow_data))
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
BOOST_LOG_TRIVIAL(error) << "Gizmos manager failed to load arrow texture.";
|
||||
|
||||
// m_main_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
||||
|
@ -5129,7 +5088,7 @@ bool GLCanvas3D::_init_undoredo_toolbar()
|
|||
}
|
||||
|
||||
// init arrow
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (!m_undoredo_toolbar.init_arrow("toolbar_arrow_2.svg"))
|
||||
#else
|
||||
BackgroundTexture::Metadata arrow_data;
|
||||
|
@ -5139,7 +5098,7 @@ bool GLCanvas3D::_init_undoredo_toolbar()
|
|||
arrow_data.right = 0;
|
||||
arrow_data.bottom = 0;
|
||||
if (!m_undoredo_toolbar.init_arrow(arrow_data))
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
BOOST_LOG_TRIVIAL(error) << "Undo/Redo toolbar failed to load arrow texture.";
|
||||
|
||||
// m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
||||
|
@ -5350,25 +5309,21 @@ void GLCanvas3D::_picking_pass()
|
|||
|
||||
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_camera_clipping_plane = m_gizmos.get_clipping_plane();
|
||||
if (m_camera_clipping_plane.is_active()) {
|
||||
::glClipPlane(GL_CLIP_PLANE0, (GLdouble*)m_camera_clipping_plane.get_data().data());
|
||||
::glClipPlane(GL_CLIP_PLANE0, (GLdouble*)m_camera_clipping_plane.get_data());
|
||||
::glEnable(GL_CLIP_PLANE0);
|
||||
}
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
_render_volumes_for_picking();
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (m_camera_clipping_plane.is_active())
|
||||
::glDisable(GL_CLIP_PLANE0);
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
_render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward());
|
||||
#else
|
||||
_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
m_gizmos.render_current_gizmo_for_picking_pass();
|
||||
|
||||
|
@ -5424,12 +5379,12 @@ void GLCanvas3D::_rectangular_selection_picking_pass()
|
|||
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
||||
|
||||
_render_volumes_for_picking();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
_render_bed_for_picking(camera.get_view_matrix(), camera.get_projection_matrix(), !camera.is_looking_downward());
|
||||
#else
|
||||
_render_bed_for_picking(!wxGetApp().plater()->get_camera().is_looking_downward());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
if (m_multisample_allowed)
|
||||
glsafe(::glEnable(GL_MULTISAMPLE));
|
||||
|
@ -5502,13 +5457,13 @@ void GLCanvas3D::_render_background()
|
|||
use_error_color &= m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed();
|
||||
}
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glLoadIdentity());
|
||||
glsafe(::glMatrixMode(GL_PROJECTION));
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glLoadIdentity());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// Draws a bottom to top gradient over the complete screen.
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
@ -5559,18 +5514,18 @@ void GLCanvas3D::_render_background()
|
|||
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
glsafe(::glMatrixMode(GL_MODELVIEW));
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void GLCanvas3D::_render_bed(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_axes)
|
||||
#else
|
||||
void GLCanvas3D::_render_bed(bool bottom, bool show_axes)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
float scale_factor = 1.0;
|
||||
#if ENABLE_RETINA_GL
|
||||
|
@ -5584,29 +5539,29 @@ void GLCanvas3D::_render_bed(bool bottom, bool show_axes)
|
|||
&& m_gizmos.get_current_type() != GLGizmosManager::Seam
|
||||
&& m_gizmos.get_current_type() != GLGizmosManager::MmuSegmentation);
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_bed.render(*this, view_matrix, projection_matrix, bottom, scale_factor, show_axes, show_texture);
|
||||
#else
|
||||
m_bed.render(*this, bottom, scale_factor, show_axes, show_texture);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void GLCanvas3D::_render_bed_for_picking(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom)
|
||||
#else
|
||||
void GLCanvas3D::_render_bed_for_picking(bool bottom)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
float scale_factor = 1.0;
|
||||
#if ENABLE_RETINA_GL
|
||||
scale_factor = m_retina_helper->get_scale_factor();
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_bed.render_for_picking(*this, view_matrix, projection_matrix, bottom, scale_factor);
|
||||
#else
|
||||
m_bed.render_for_picking(*this, bottom, scale_factor);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
||||
|
@ -5674,7 +5629,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)) {
|
||||
int object_id = m_layers_editing.last_object_id;
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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) {
|
||||
// Which volume to paint without the layer height profile shader?
|
||||
|
@ -5685,13 +5640,13 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
|||
// Which volume to paint without the layer height profile shader?
|
||||
return volume.is_active && (volume.is_modifier || volume.composite_id.object_id != object_id);
|
||||
});
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
// Let LayersEditing handle rendering of the active object using the layer height profile shader.
|
||||
m_layers_editing.render_volumes(*this, m_volumes);
|
||||
}
|
||||
else {
|
||||
// do not cull backfaces to show broken geometry, if any
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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) {
|
||||
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
|
||||
|
@ -5700,7 +5655,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) {
|
||||
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
|
||||
});
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
// In case a painting gizmo is open, it should render the painted triangles
|
||||
|
@ -5719,12 +5674,12 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type)
|
|||
}
|
||||
case GLVolumeCollection::ERenderType::Transparent:
|
||||
{
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
m_volumes.render(type, false, camera.get_view_matrix(), camera.get_projection_matrix());
|
||||
#else
|
||||
m_volumes.render(type, false, wxGetApp().plater()->get_camera().get_view_matrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -5832,7 +5787,7 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
|
|||
void GLCanvas3D::_render_overlays()
|
||||
{
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glLoadIdentity());
|
||||
// ensure that the textures are renderered inside the frustrum
|
||||
|
@ -5841,7 +5796,7 @@ void GLCanvas3D::_render_overlays()
|
|||
// ensure that the overlay fits the frustrum near z plane
|
||||
double gui_scale = camera.get_gui_scale();
|
||||
glsafe(::glScaled(gui_scale, gui_scale, 1.0));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
_check_and_update_toolbar_icon_scale();
|
||||
|
||||
|
@ -5880,19 +5835,15 @@ void GLCanvas3D::_render_overlays()
|
|||
}
|
||||
m_labels.render(sorted_instances);
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
void GLCanvas3D::_render_volumes_for_picking() const
|
||||
{
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat_clip");
|
||||
#else
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
@ -5900,10 +5851,10 @@ void GLCanvas3D::_render_volumes_for_picking() const
|
|||
// do not cull backfaces to show broken geometry, if any
|
||||
glsafe(::glDisable(GL_CULL_FACE));
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
const Transform3d& view_matrix = wxGetApp().plater()->get_camera().get_view_matrix();
|
||||
for (size_t type = 0; type < 2; ++ type) {
|
||||
|
@ -5917,17 +5868,12 @@ void GLCanvas3D::_render_volumes_for_picking() const
|
|||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
volume.first->model.set_color(picking_decode(id));
|
||||
shader->start_using();
|
||||
#else
|
||||
glsafe(::glColor4fv(picking_decode(id).data()));
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
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("volume_world_matrix", volume.first->world_matrix());
|
||||
shader->set_uniform("z_range", m_volumes.get_z_range());
|
||||
shader->set_uniform("clipping_plane", m_volumes.get_clipping_plane());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#else
|
||||
glsafe(::glColor4fv(picking_decode(id).data()));
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
volume.first->render();
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->stop_using();
|
||||
|
@ -5935,10 +5881,10 @@ void GLCanvas3D::_render_volumes_for_picking() const
|
|||
}
|
||||
}
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
|
||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
glsafe(::glEnable(GL_CULL_FACE));
|
||||
}
|
||||
|
@ -5973,20 +5919,20 @@ void GLCanvas3D::_render_main_toolbar()
|
|||
return;
|
||||
|
||||
const Size cnv_size = get_canvas_size();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const float top = 0.5f * (float)cnv_size.get_height();
|
||||
#else
|
||||
const float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||
const float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
const float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width);
|
||||
#else
|
||||
const float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width) * inv_zoom;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
m_main_toolbar.set_position(top, left);
|
||||
m_main_toolbar.render(*this);
|
||||
|
@ -6000,20 +5946,20 @@ void GLCanvas3D::_render_undoredo_toolbar()
|
|||
return;
|
||||
|
||||
const Size cnv_size = get_canvas_size();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const float top = 0.5f * (float)cnv_size.get_height();
|
||||
#else
|
||||
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||
|
||||
const float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
const float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0.0f;
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const float left = m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar_width);
|
||||
#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;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
m_undoredo_toolbar.set_position(top, left);
|
||||
m_undoredo_toolbar.render(*this);
|
||||
|
@ -6027,7 +5973,7 @@ void GLCanvas3D::_render_collapse_toolbar() const
|
|||
|
||||
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;
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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;
|
||||
#else
|
||||
|
@ -6035,7 +5981,7 @@ void GLCanvas3D::_render_collapse_toolbar() const
|
|||
|
||||
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;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
collapse_toolbar.set_position(top, left);
|
||||
collapse_toolbar.render(*this);
|
||||
|
@ -6059,17 +6005,17 @@ void GLCanvas3D::_render_view_toolbar() const
|
|||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
const Size cnv_size = get_canvas_size();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
// 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 left = -0.5f * (float)cnv_size.get_width();
|
||||
const float top = -0.5f * (float)cnv_size.get_height() + view_toolbar.get_height();
|
||||
const float left = -0.5f * (float)cnv_size.get_width();
|
||||
#else
|
||||
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
|
||||
|
||||
// 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 left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
view_toolbar.set_position(top, left);
|
||||
view_toolbar.render(*this);
|
||||
}
|
||||
|
@ -6126,17 +6072,17 @@ void GLCanvas3D::_render_camera_target()
|
|||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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() * Geometry::assemble_transform(m_camera_target.target));
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
const std::array<int, 4>& viewport = camera.get_viewport();
|
||||
shader->set_uniform("viewport_size", Vec2d(double(viewport[2]), double(viewport[3])));
|
||||
shader->set_uniform("width", 1.5f);
|
||||
shader->set_uniform("width", 0.5f);
|
||||
shader->set_uniform("gap_size", 0.0f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
m_camera_target.axis[i].render();
|
||||
}
|
||||
|
@ -6315,32 +6261,19 @@ void GLCanvas3D::_render_sla_slices()
|
|||
shader->start_using();
|
||||
|
||||
for (const SLAPrintObject::Instance& inst : obj->instances()) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
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),
|
||||
inst.rotation * Vec3d::UnitZ(), Vec3d::Ones(),
|
||||
obj->is_left_handed() ? Vec3d(-1.0f, 1.0f, 1.0f) : Vec3d::Ones());
|
||||
obj->is_left_handed() ? /* The polygons are mirrored by X */ Vec3d(-1.0f, 1.0f, 1.0f) : Vec3d::Ones());
|
||||
|
||||
shader->set_uniform("view_model_matrix", view_model_matrix);
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(unscale<double>(inst.shift.x()), unscale<double>(inst.shift.y()), 0.0));
|
||||
glsafe(::glRotatef(Geometry::rad2deg(inst.rotation), 0.0f, 0.0f, 1.0f));
|
||||
if (obj->is_left_handed())
|
||||
// The polygons are mirrored by X.
|
||||
glsafe(::glScalef(-1.0f, 1.0f, 1.0f));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
bottom_obj_triangles.render();
|
||||
top_obj_triangles.render();
|
||||
bottom_sup_triangles.render();
|
||||
top_sup_triangles.render();
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
|
||||
shader->stop_using();
|
||||
|
|
|
@ -245,15 +245,8 @@ class GLCanvas3D
|
|||
GLModel baseline;
|
||||
GLModel profile;
|
||||
GLModel background;
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
float old_canvas_width{ 0.0f };
|
||||
#else
|
||||
Rect old_bar_rect;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
std::vector<double> old_layer_height_profile;
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
bool dirty{ false };
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
};
|
||||
Profile m_profile;
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
@ -283,9 +276,9 @@ class GLCanvas3D
|
|||
static float get_cursor_z_relative(const GLCanvas3D& canvas);
|
||||
static bool bar_rect_contains(const GLCanvas3D& canvas, float x, float y);
|
||||
static Rect get_bar_rect_screen(const GLCanvas3D& canvas);
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
static Rect get_bar_rect_viewport(const GLCanvas3D& canvas);
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
static float get_overlay_window_width() { return LayersEditing::s_overlay_window_width; }
|
||||
|
||||
float object_max_z() const { return m_object_max_z; }
|
||||
|
@ -295,13 +288,13 @@ class GLCanvas3D
|
|||
private:
|
||||
bool is_initialized() const;
|
||||
void generate_layer_height_texture();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void render_active_object_annotations(const GLCanvas3D& canvas);
|
||||
void render_profile(const GLCanvas3D& canvas);
|
||||
#else
|
||||
void render_active_object_annotations(const GLCanvas3D& canvas, const Rect& bar_rect);
|
||||
void render_profile(const Rect& bar_rect);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void update_slicing_parameters();
|
||||
|
||||
static float thickness_bar_width(const GLCanvas3D &canvas);
|
||||
|
@ -953,13 +946,13 @@ private:
|
|||
void _picking_pass();
|
||||
void _rectangular_selection_picking_pass();
|
||||
void _render_background();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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);
|
||||
#else
|
||||
void _render_bed(bool bottom, bool show_axes);
|
||||
void _render_bed_for_picking(bool bottom);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void _render_objects(GLVolumeCollection::ERenderType type);
|
||||
void _render_gcode();
|
||||
#if ENABLE_SHOW_TOOLPATHS_COG
|
||||
|
|
|
@ -900,47 +900,30 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
|||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, m_render_data.vbo_id));
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
int position_id = -1;
|
||||
int normal_id = -1;
|
||||
int tex_coord_id = -1;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
if (position) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
position_id = shader->get_attrib_location("v_position");
|
||||
if (position_id != -1) {
|
||||
glsafe(::glVertexAttribPointer(position_id, Geometry::position_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (const void*)Geometry::position_offset_bytes(data.format)));
|
||||
glsafe(::glEnableVertexAttribArray(position_id));
|
||||
}
|
||||
#else
|
||||
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));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
if (normal) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
normal_id = shader->get_attrib_location("v_normal");
|
||||
if (normal_id != -1) {
|
||||
glsafe(::glVertexAttribPointer(normal_id, Geometry::normal_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (const void*)Geometry::normal_offset_bytes(data.format)));
|
||||
glsafe(::glEnableVertexAttribArray(normal_id));
|
||||
}
|
||||
#else
|
||||
glsafe(::glNormalPointer(GL_FLOAT, vertex_stride_bytes, (const void*)Geometry::normal_offset_bytes(data.format)));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
if (tex_coord) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
tex_coord_id = shader->get_attrib_location("v_tex_coord");
|
||||
if (tex_coord_id != -1) {
|
||||
glsafe(::glVertexAttribPointer(tex_coord_id, Geometry::tex_coord_stride_floats(data.format), GL_FLOAT, GL_FALSE, vertex_stride_bytes, (const void*)Geometry::tex_coord_offset_bytes(data.format)));
|
||||
glsafe(::glEnableVertexAttribArray(tex_coord_id));
|
||||
}
|
||||
#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(::glEnableClientState(GL_TEXTURE_COORD_ARRAY));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
|
||||
shader->set_uniform("uniform_color", data.color);
|
||||
|
@ -953,21 +936,12 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
|
|||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||
#endif // !ENABLE_GL_CORE_PROFILE
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (tex_coord_id != -1)
|
||||
glsafe(::glDisableVertexAttribArray(tex_coord_id));
|
||||
if (normal_id != -1)
|
||||
glsafe(::glDisableVertexAttribArray(normal_id));
|
||||
if (position_id != -1)
|
||||
glsafe(::glDisableVertexAttribArray(position_id));
|
||||
#else
|
||||
if (tex_coord)
|
||||
glsafe(::glDisableClientState(GL_TEXTURE_COORD_ARRAY));
|
||||
if (normal)
|
||||
glsafe(::glDisableClientState(GL_NORMAL_ARRAY));
|
||||
if (position)
|
||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
|
@ -1464,61 +1438,61 @@ GLModel::Geometry stilized_arrow(unsigned int resolution, float tip_radius, floa
|
|||
}
|
||||
#else
|
||||
append_vertex(entity, { 0.0f, 0.0f, total_height }, Vec3f::UnitZ());
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
append_vertex(entity, { tip_radius * sines[i], tip_radius * cosines[i], stem_height }, { sines[i], cosines[i], 0.0f });
|
||||
}
|
||||
|
||||
// tip triangles
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
const int v3 = (i < resolution - 1) ? i + 2 : 1;
|
||||
append_indices(entity, 0, i + 1, v3);
|
||||
}
|
||||
|
||||
// tip cap outer perimeter vertices
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
append_vertex(entity, { tip_radius * sines[i], tip_radius * cosines[i], stem_height }, -Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
// tip cap inner perimeter vertices
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
append_vertex(entity, { stem_radius * sines[i], stem_radius * cosines[i], stem_height }, -Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
// tip cap triangles
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
const int v2 = (i < resolution - 1) ? i + resolution + 2 : resolution + 1;
|
||||
const int v3 = (i < resolution - 1) ? i + 2 * resolution + 2 : 2 * resolution + 1;
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
const unsigned int v2 = (i < resolution - 1) ? i + resolution + 2 : resolution + 1;
|
||||
const unsigned int v3 = (i < resolution - 1) ? i + 2 * resolution + 2 : 2 * resolution + 1;
|
||||
append_indices(entity, i + resolution + 1, v3, v2);
|
||||
append_indices(entity, i + resolution + 1, i + 2 * resolution + 1, v3);
|
||||
}
|
||||
|
||||
// stem bottom vertices
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
append_vertex(entity, { stem_radius * sines[i], stem_radius * cosines[i], stem_height }, { sines[i], cosines[i], 0.0f });
|
||||
}
|
||||
|
||||
// stem top vertices
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
append_vertex(entity, { stem_radius * sines[i], stem_radius * cosines[i], 0.0f }, { sines[i], cosines[i], 0.0f });
|
||||
}
|
||||
|
||||
// stem triangles
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
const int v2 = (i < resolution - 1) ? i + 3 * resolution + 2 : 3 * resolution + 1;
|
||||
const int v3 = (i < resolution - 1) ? i + 4 * resolution + 2 : 4 * resolution + 1;
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
const int unsigned v2 = (i < resolution - 1) ? i + 3 * resolution + 2 : 3 * resolution + 1;
|
||||
const int unsigned v3 = (i < resolution - 1) ? i + 4 * resolution + 2 : 4 * resolution + 1;
|
||||
append_indices(entity, i + 3 * resolution + 1, v3, v2);
|
||||
append_indices(entity, i + 3 * resolution + 1, i + 4 * resolution + 1, v3);
|
||||
}
|
||||
|
||||
// stem cap vertices
|
||||
append_vertex(entity, Vec3f::Zero(), -Vec3f::UnitZ());
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
append_vertex(entity, { stem_radius * sines[i], stem_radius * cosines[i], 0.0f }, -Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
// stem cap triangles
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
const int v3 = (i < resolution - 1) ? i + 5 * resolution + 3 : 5 * resolution + 2;
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
const unsigned int v3 = (i < resolution - 1) ? i + 5 * resolution + 3 : 5 * resolution + 2;
|
||||
append_indices(entity, 5 * resolution + 1, v3, i + 5 * resolution + 2);
|
||||
}
|
||||
|
||||
|
@ -1766,57 +1740,57 @@ GLModel::Geometry circular_arrow(unsigned int resolution, float radius, float ti
|
|||
|
||||
// stem
|
||||
// top face vertices
|
||||
for (int i = 0; i <= resolution; ++i) {
|
||||
for (unsigned int i = 0; i <= resolution; ++i) {
|
||||
const float angle = static_cast<float>(i) * step_angle;
|
||||
append_vertex(entity, { inner_radius * ::sin(angle), inner_radius * ::cos(angle), half_thickness }, Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
for (int i = 0; i <= resolution; ++i) {
|
||||
for (unsigned int i = 0; i <= resolution; ++i) {
|
||||
const float angle = static_cast<float>(i) * step_angle;
|
||||
append_vertex(entity, { outer_radius * ::sin(angle), outer_radius * ::cos(angle), half_thickness }, Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
// top face triangles
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
append_indices(entity, 26 + i, 27 + i, 27 + resolution + i);
|
||||
append_indices(entity, 27 + i, 28 + resolution + i, 27 + resolution + i);
|
||||
}
|
||||
|
||||
// bottom face vertices
|
||||
for (int i = 0; i <= resolution; ++i) {
|
||||
for (unsigned int i = 0; i <= resolution; ++i) {
|
||||
const float angle = static_cast<float>(i) * step_angle;
|
||||
append_vertex(entity, { inner_radius * ::sin(angle), inner_radius * ::cos(angle), -half_thickness }, -Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
for (int i = 0; i <= resolution; ++i) {
|
||||
for (unsigned int i = 0; i <= resolution; ++i) {
|
||||
const float angle = static_cast<float>(i) * step_angle;
|
||||
append_vertex(entity, { outer_radius * ::sin(angle), outer_radius * ::cos(angle), -half_thickness }, -Vec3f::UnitZ());
|
||||
}
|
||||
|
||||
// bottom face triangles
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
append_indices(entity, 28 + 2 * resolution + i, 29 + 3 * resolution + i, 29 + 2 * resolution + i);
|
||||
append_indices(entity, 29 + 2 * resolution + i, 29 + 3 * resolution + i, 30 + 3 * resolution + i);
|
||||
}
|
||||
|
||||
// side faces vertices and triangles
|
||||
for (int i = 0; i <= resolution; ++i) {
|
||||
for (unsigned int i = 0; i <= resolution; ++i) {
|
||||
const float angle = static_cast<float>(i) * step_angle;
|
||||
const float c = ::cos(angle);
|
||||
const float s = ::sin(angle);
|
||||
append_vertex(entity, { inner_radius * s, inner_radius * c, -half_thickness }, { -s, -c, 0.0f });
|
||||
}
|
||||
|
||||
for (int i = 0; i <= resolution; ++i) {
|
||||
for (unsigned int i = 0; i <= resolution; ++i) {
|
||||
const float angle = static_cast<float>(i) * step_angle;
|
||||
const float c = ::cos(angle);
|
||||
const float s = ::sin(angle);
|
||||
append_vertex(entity, { inner_radius * s, inner_radius * c, half_thickness }, { -s, -c, 0.0f });
|
||||
}
|
||||
|
||||
int first_id = 26 + 4 * (resolution + 1);
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
const int ii = first_id + i;
|
||||
unsigned int first_id = 26 + 4 * (resolution + 1);
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
const unsigned int ii = first_id + i;
|
||||
append_indices(entity, ii, ii + 1, ii + resolution + 2);
|
||||
append_indices(entity, ii, ii + resolution + 2, ii + resolution + 1);
|
||||
}
|
||||
|
@ -1830,14 +1804,14 @@ GLModel::Geometry circular_arrow(unsigned int resolution, float radius, float ti
|
|||
append_indices(entity, first_id, first_id + 1, first_id + 3);
|
||||
append_indices(entity, first_id, first_id + 3, first_id + 2);
|
||||
|
||||
for (int i = resolution; i >= 0; --i) {
|
||||
for (int i = int(resolution); i >= 0; --i) {
|
||||
const float angle = static_cast<float>(i) * step_angle;
|
||||
const float c = ::cos(angle);
|
||||
const float s = ::sin(angle);
|
||||
append_vertex(entity, { outer_radius * s, outer_radius * c, -half_thickness }, { s, c, 0.0f });
|
||||
}
|
||||
|
||||
for (int i = resolution; i >= 0; --i) {
|
||||
for (int i = int(resolution); i >= 0; --i) {
|
||||
const float angle = static_cast<float>(i) * step_angle;
|
||||
const float c = ::cos(angle);
|
||||
const float s = ::sin(angle);
|
||||
|
@ -1845,8 +1819,8 @@ GLModel::Geometry circular_arrow(unsigned int resolution, float radius, float ti
|
|||
}
|
||||
|
||||
first_id = 30 + 6 * (resolution + 1);
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
const int ii = first_id + i;
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
const unsigned int ii = first_id + i;
|
||||
append_indices(entity, ii, ii + 1, ii + resolution + 2);
|
||||
append_indices(entity, ii, ii + resolution + 2, ii + resolution + 1);
|
||||
}
|
||||
|
@ -2093,8 +2067,8 @@ GLModel::Geometry diamond(unsigned int resolution)
|
|||
data.add_triangle(resolution - 1, resolution + 1, 0);
|
||||
#else
|
||||
// positions
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
float ii = float(i) * step;
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
const float ii = float(i) * step;
|
||||
entity.positions.emplace_back(0.5f * ::cos(ii), 0.5f * ::sin(ii), 0.0f);
|
||||
}
|
||||
entity.positions.emplace_back(0.0f, 0.0f, 0.5f);
|
||||
|
@ -2107,7 +2081,7 @@ GLModel::Geometry diamond(unsigned int resolution)
|
|||
|
||||
// triangles
|
||||
// top
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
entity.indices.push_back(i + 0);
|
||||
entity.indices.push_back(i + 1);
|
||||
entity.indices.push_back(resolution);
|
||||
|
@ -2117,7 +2091,7 @@ GLModel::Geometry diamond(unsigned int resolution)
|
|||
entity.indices.push_back(resolution);
|
||||
|
||||
// bottom
|
||||
for (int i = 0; i < resolution; ++i) {
|
||||
for (unsigned int i = 0; i < resolution; ++i) {
|
||||
entity.indices.push_back(i + 0);
|
||||
entity.indices.push_back(resolution + 1);
|
||||
entity.indices.push_back(i + 1);
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace GUI {
|
|||
return;
|
||||
|
||||
const Size cnv_size = canvas.get_canvas_size();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const float cnv_width = (float)cnv_size.get_width();
|
||||
const float cnv_height = (float)cnv_size.get_height();
|
||||
if (cnv_width == 0.0f || cnv_height == 0.0f)
|
||||
|
@ -103,7 +103,7 @@ namespace GUI {
|
|||
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 bottom = (float)std::min(start.y(), end.y()) * inv_zoom;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glLineWidth(1.5f));
|
||||
|
@ -118,7 +118,7 @@ namespace GUI {
|
|||
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glLoadIdentity());
|
||||
// ensure that the rectangle is renderered inside the frustrum
|
||||
|
@ -126,7 +126,7 @@ namespace GUI {
|
|||
// ensure that the overlay fits the frustrum near z plane
|
||||
const double gui_scale = camera.get_gui_scale();
|
||||
glsafe(::glScaled(gui_scale, gui_scale, 1.0));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glPushAttrib(GL_ENABLE_BIT));
|
||||
|
@ -202,7 +202,6 @@ namespace GUI {
|
|||
m_rectangle.init_from(std::move(init_data));
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
|
@ -212,7 +211,6 @@ namespace GUI {
|
|||
shader->set_uniform("dash_size", 0.01f);
|
||||
shader->set_uniform("gap_size", 0.0075f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
m_rectangle.set_color(ColorRGBA((m_state == EState::Select) ? 0.3f : 1.0f, (m_state == EState::Select) ? 1.0f : 0.3f, 0.3f, 1.0f));
|
||||
m_rectangle.render();
|
||||
|
@ -231,9 +229,9 @@ namespace GUI {
|
|||
glsafe(::glPopAttrib());
|
||||
#endif // !ENABLE_GL_CORE_PROFILE
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
|
|
|
@ -301,12 +301,12 @@ void GLShaderProgram::set_uniform(int id, const Matrix3f& value) const
|
|||
glsafe(::glUniformMatrix3fv(id, 1, GL_FALSE, static_cast<const GLfloat*>(value.data())));
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void GLShaderProgram::set_uniform(int id, const Matrix3d& value) const
|
||||
{
|
||||
set_uniform(id, (Matrix3f)value.cast<float>());
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_IMGUI_SHADERS
|
||||
void GLShaderProgram::set_uniform(int id, const Matrix4f& value) const
|
||||
|
|
|
@ -62,9 +62,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 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); }
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void set_uniform(const char* name, const Matrix3d& value) const { set_uniform(get_uniform_location(name), value); }
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_IMGUI_SHADERS
|
||||
void set_uniform(const char* name, const Matrix4f& value) const { set_uniform(get_uniform_location(name), value); }
|
||||
void set_uniform(const char* name, const Matrix4d& value) const { set_uniform(get_uniform_location(name), value); }
|
||||
|
@ -93,9 +93,9 @@ public:
|
|||
void set_uniform(int id, const Transform3f& value) const;
|
||||
void set_uniform(int id, const Transform3d& value) const;
|
||||
void set_uniform(int id, const Matrix3f& value) const;
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void set_uniform(int id, const Matrix3d& value) const;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_IMGUI_SHADERS
|
||||
void set_uniform(int id, const Matrix4f& value) const;
|
||||
void set_uniform(int id, const Matrix4d& value) const;
|
||||
|
|
|
@ -34,7 +34,6 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||
bool valid = true;
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const std::string prefix = GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 1) ? "140/" : "110/";
|
||||
// imgui shader
|
||||
valid &= append_shader("imgui", { prefix + "imgui.vs", prefix + "imgui.fs" });
|
||||
|
@ -50,24 +49,16 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||
// used to render thick and/or dashed lines
|
||||
valid &= append_shader("dashed_thick_lines", { prefix + "dashed_thick_lines.vs", prefix + "dashed_thick_lines.fs", prefix + "dashed_thick_lines.gs" });
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#else
|
||||
// basic shader, used to render all what was previously rendered using the immediate mode
|
||||
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" });
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_SHOW_TOOLPATHS_COG
|
||||
// used to render toolpaths center of gravity
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
valid &= append_shader("toolpaths_cog", { prefix + "toolpaths_cog.vs", prefix + "toolpaths_cog.fs" });
|
||||
#else
|
||||
valid &= append_shader("toolpaths_cog", { "toolpaths_cog.vs", "toolpaths_cog.fs" });
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#endif // ENABLE_SHOW_TOOLPATHS_COG
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
// 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", { prefix + "gouraud_light.vs", prefix + "gouraud_light.fs" });
|
||||
// used to render printbed
|
||||
|
@ -77,16 +68,16 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||
valid &= append_shader("gouraud_light", { "gouraud_light.vs", "gouraud_light.fs" });
|
||||
// used to render printbed
|
||||
valid &= append_shader("printbed", { "printbed.vs", "printbed.fs" });
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
// used to render options in gcode preview
|
||||
if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 3)) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
valid &= append_shader("gouraud_light_instanced", { prefix + "gouraud_light_instanced.vs", prefix + "gouraud_light_instanced.fs" });
|
||||
#else
|
||||
valid &= append_shader("gouraud_light_instanced", { "gouraud_light_instanced.vs", "gouraud_light_instanced.fs" });
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
// used to render objects in 3d editor
|
||||
valid &= append_shader("gouraud", { prefix + "gouraud.vs", prefix + "gouraud.fs" }
|
||||
#else
|
||||
|
@ -94,12 +85,12 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||
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" }
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
, { "ENABLE_ENVIRONMENT_MAP"sv }
|
||||
#endif // ENABLE_ENVIRONMENT_MAP
|
||||
);
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
// used to render variable layers heights in 3d editor
|
||||
valid &= append_shader("variable_layer_height", { prefix + "variable_layer_height.vs", prefix + "variable_layer_height.fs" });
|
||||
// used to render highlight contour around selected triangles inside the multi-material gizmo
|
||||
|
@ -109,14 +100,14 @@ std::pair<bool, std::string> GLShadersManager::init()
|
|||
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" });
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
// 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.
|
||||
// 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.
|
||||
// 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.
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (platform_flavor() == PlatformFlavor::OSXOnArm && wxPlatformInfo::Get().GetOSMajorVersion() < 12)
|
||||
valid &= append_shader("mm_gouraud", { prefix + "mm_gouraud.vs", prefix + "mm_gouraud.fs" }, { "FLIP_TRIANGLE_NORMALS"sv });
|
||||
else
|
||||
|
@ -126,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});
|
||||
else
|
||||
valid &= append_shader("mm_gouraud", {"mm_gouraud.vs", "mm_gouraud.fs"});
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
return { valid, error };
|
||||
}
|
||||
|
|
|
@ -363,10 +363,10 @@ void GLTexture::render_sub_texture(unsigned int tex_id, float left, float right,
|
|||
GLShaderProgram* shader = wxGetApp().get_shader("flat_texture");
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
model.render();
|
||||
shader->stop_using();
|
||||
}
|
||||
|
|
|
@ -85,11 +85,11 @@ bool GLToolbarItem::update_enabled_state()
|
|||
return ret;
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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
|
||||
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_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
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);
|
||||
|
@ -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));
|
||||
|
||||
if (is_pressed()) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Size cnv_size = parent.get_canvas_size();
|
||||
const float cnv_w = (float)cnv_size.get_width();
|
||||
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);
|
||||
else if (m_last_action_type == Right && m_data.right.can_render())
|
||||
m_data.right.render_callback(left, right, bottom, top);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ bool GLToolbar::init(const BackgroundTexture::Metadata& background_texture)
|
|||
return res;
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
bool GLToolbar::init_arrow(const std::string& filename)
|
||||
{
|
||||
if (m_arrow_texture.get_id() != 0)
|
||||
|
@ -228,7 +228,7 @@ bool GLToolbar::init_arrow(const BackgroundTexture::Metadata& arrow_texture)
|
|||
|
||||
return res;
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
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_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
||||
{
|
||||
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_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
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_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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();
|
||||
|
@ -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 } });
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void GLToolbar::render_arrow(const GLCanvas3D& parent, GLToolbarItem* highlighted_item)
|
||||
{
|
||||
// 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 } });
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void GLToolbar::render_horizontal(const GLCanvas3D& parent)
|
||||
{
|
||||
const Size cnv_size = parent.get_canvas_size();
|
||||
|
@ -1927,7 +1927,7 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
bool GLToolbar::generate_icons_texture()
|
||||
{
|
||||
|
|
|
@ -153,11 +153,11 @@ public:
|
|||
// returns true if the state changes
|
||||
bool update_enabled_state();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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
|
||||
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_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
private:
|
||||
void set_visible(bool visible) { m_data.visible = visible; }
|
||||
|
@ -251,11 +251,11 @@ private:
|
|||
GLTexture m_icons_texture;
|
||||
bool m_icons_texture_dirty;
|
||||
BackgroundTexture m_background_texture;
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
GLTexture m_arrow_texture;
|
||||
#else
|
||||
BackgroundTexture m_arrow_texture;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
Layout m_layout;
|
||||
|
||||
ItemsList m_items;
|
||||
|
@ -282,11 +282,11 @@ public:
|
|||
|
||||
bool init(const BackgroundTexture::Metadata& background_texture);
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
bool init_arrow(const std::string& filename);
|
||||
#else
|
||||
bool init_arrow(const BackgroundTexture::Metadata& arrow_texture);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
Layout::EType get_layout_type() const;
|
||||
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_vertical(const Vec2d& mouse_pos, const GLCanvas3D& parent) const;
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void render_background(float left, float top, float right, float bottom, float border_w, float border_h) const;
|
||||
#else
|
||||
void render_background(float left, float top, float right, float bottom, float border) const;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void render_horizontal(const GLCanvas3D& parent);
|
||||
void render_vertical(const GLCanvas3D& parent);
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// TODO: Display tooltips quicker on Linux
|
||||
|
||||
|
@ -44,11 +44,11 @@ float GLGizmoBase::Grabber::get_dragging_half_size(float size) const
|
|||
|
||||
void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, bool picking)
|
||||
{
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
GLShaderProgram* shader = wxGetApp().get_current_shader();
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GIZMO_GRABBER_REFACTOR
|
||||
if (!s_cube.is_initialized()) {
|
||||
|
@ -101,7 +101,6 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo
|
|||
#endif // ENABLE_GIZMO_GRABBER_REFACTOR
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
#if ENABLE_GIZMO_GRABBER_REFACTOR
|
||||
const Transform3d view_model_matrix = camera.get_view_matrix() * matrix * Geometry::assemble_transform(center, angles, 2.0 * half_size * Vec3d::Ones());
|
||||
|
@ -124,11 +123,10 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo
|
|||
#else
|
||||
glsafe(::glScaled(fullsize, fullsize, fullsize));
|
||||
#endif // ENABLE_GIZMO_GRABBER_REFACTOR
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GIZMO_GRABBER_REFACTOR
|
||||
s_cube.render();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if ((int(extensions) & int(GLGizmoBase::EGrabberExtension::PosX)) != 0) {
|
||||
shader->set_uniform("view_model_matrix", view_model_matrix * Geometry::assemble_transform(Vec3d::UnitX(), Vec3d(0.0, 0.5 * double(PI), 0.0)));
|
||||
s_cone.render();
|
||||
|
@ -195,13 +193,13 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo
|
|||
s_cone.render();
|
||||
glsafe(::glPopMatrix());
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#else
|
||||
m_cube.render();
|
||||
#endif // ENABLE_GIZMO_GRABBER_REFACTOR
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
|
|
|
@ -62,9 +62,9 @@ protected:
|
|||
bool dragging{ false };
|
||||
Vec3d center{ Vec3d::Zero() };
|
||||
Vec3d angles{ Vec3d::Zero() };
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
Transform3d matrix{ Transform3d::Identity() };
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
ColorRGBA color{ ColorRGBA::WHITE() };
|
||||
#if ENABLE_GIZMO_GRABBER_REFACTOR
|
||||
EGrabberExtension extensions{ EGrabberExtension::None };
|
||||
|
|
|
@ -149,11 +149,9 @@ void GLGizmoCut::on_render()
|
|||
m_plane.init_from(std::move(init_data));
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
m_plane.render();
|
||||
#else
|
||||
|
@ -251,25 +249,23 @@ void GLGizmoCut::on_render()
|
|||
shader = wxGetApp().get_shader("flat");
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
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("projection_matrix", camera.get_projection_matrix());
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(m_cut_contours.shift.x(), m_cut_contours.shift.y(), m_cut_contours.shift.z()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(m_cut_contours.shift.x(), m_cut_contours.shift.y(), m_cut_contours.shift.z()));
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glLineWidth(2.0f));
|
||||
#endif // !ENABLE_GL_CORE_PROFILE
|
||||
m_cut_contours.contours.render();
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->stop_using();
|
||||
}
|
||||
#else
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#endif // !ENABLE_GL_CORE_PROFILE
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@
|
|||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
|
||||
|
||||
|
@ -119,7 +117,7 @@ void GLGizmoFlatten::on_render()
|
|||
|
||||
if (selection.is_single_full_instance()) {
|
||||
const Transform3d& m = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
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;
|
||||
|
@ -130,7 +128,7 @@ void GLGizmoFlatten::on_render()
|
|||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(0.f, 0.f, selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z()));
|
||||
glsafe(::glMultMatrixd(m.data()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (this->is_plane_update_necessary())
|
||||
update_planes();
|
||||
for (int i = 0; i < (int)m_planes.size(); ++i) {
|
||||
|
@ -143,9 +141,9 @@ void GLGizmoFlatten::on_render()
|
|||
m_planes[i].vbo.render();
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
glsafe(::glEnable(GL_CULL_FACE));
|
||||
|
@ -173,7 +171,7 @@ void GLGizmoFlatten::on_render_for_picking()
|
|||
|
||||
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();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
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;
|
||||
|
@ -184,7 +182,7 @@ void GLGizmoFlatten::on_render_for_picking()
|
|||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(0.f, 0.f, selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z()));
|
||||
glsafe(::glMultMatrixd(m.data()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (this->is_plane_update_necessary())
|
||||
update_planes();
|
||||
for (int i = 0; i < (int)m_planes.size(); ++i) {
|
||||
|
@ -195,9 +193,9 @@ void GLGizmoFlatten::on_render_for_picking()
|
|||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_planes[i].vbo.render();
|
||||
}
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
glsafe(::glEnable(GL_CULL_FACE));
|
||||
|
|
|
@ -120,7 +120,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking)
|
|||
const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
Geometry::Transformation trafo = vol->get_instance_transformation() * vol->get_volume_transformation();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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()) * trafo.get_matrix();
|
||||
|
||||
|
@ -136,7 +136,7 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking)
|
|||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(0.0, 0.0, m_c->selection_info()->get_sla_shift()));
|
||||
glsafe(::glMultMatrixd(instance_matrix.data()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
ColorRGBA render_color;
|
||||
const sla::DrainHoles& drain_holes = m_c->selection_info()->model_object()->sla_drain_holes;
|
||||
|
@ -166,27 +166,24 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking)
|
|||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_cylinder.set_color(render_color);
|
||||
#else
|
||||
const_cast<GLModel*>(&m_cylinder)->set_color(-1, render_color);
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Transform3d hole_matrix = Geometry::assemble_transform(drain_hole.pos.cast<double>()) * instance_scaling_matrix_inverse;
|
||||
#else
|
||||
const_cast<GLModel*>(&m_cylinder)->set_color(-1, render_color);
|
||||
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(drain_hole.pos.x(), drain_hole.pos.y(), drain_hole.pos.z()));
|
||||
glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
if (vol->is_left_handed())
|
||||
glFrontFace(GL_CW);
|
||||
glsafe(::glFrontFace(GL_CW));
|
||||
|
||||
// Matrices set, we can render the point mark now.
|
||||
Eigen::Quaterniond q;
|
||||
q.setFromTwoVectors(Vec3d::UnitZ(), instance_scaling_matrix_inverse * (-drain_hole.normal).cast<double>());
|
||||
const Eigen::AngleAxisd aa(q);
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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));
|
||||
|
||||
|
@ -196,20 +193,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(::glTranslated(0., 0., -drain_hole.height));
|
||||
glsafe(::glScaled(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_cylinder.render();
|
||||
|
||||
if (vol->is_left_handed())
|
||||
glFrontFace(GL_CCW);
|
||||
glsafe(::glFrontFace(GL_CCW));
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
bool GLGizmoHollow::is_mesh_point_clipped(const Vec3d& point) const
|
||||
|
|
|
@ -193,7 +193,7 @@ void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const
|
|||
if (is_left_handed)
|
||||
glsafe(::glFrontFace(GL_CW));
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Transform3d matrix = camera.get_view_matrix() * trafo_matrix;
|
||||
shader->set_uniform("view_model_matrix", matrix);
|
||||
|
@ -202,19 +202,17 @@ void GLGizmoMmuSegmentation::render_triangles(const Selection &selection) const
|
|||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glMultMatrixd(trafo_matrix.data()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
shader->set_uniform("volume_world_matrix", trafo_matrix);
|
||||
shader->set_uniform("volume_mirrored", is_left_handed);
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_triangle_selectors[mesh_id]->render(m_imgui, trafo_matrix);
|
||||
#else
|
||||
m_triangle_selectors[mesh_id]->render(m_imgui);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
if (is_left_handed)
|
||||
glsafe(::glFrontFace(GL_CCW));
|
||||
}
|
||||
|
@ -583,11 +581,11 @@ ColorRGBA GLGizmoMmuSegmentation::get_cursor_sphere_right_button_color() const
|
|||
return color;
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void TriangleSelectorMmGui::render(ImGuiWrapper* imgui, const Transform3d& matrix)
|
||||
#else
|
||||
void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
if (m_update_render_data)
|
||||
update_render_data();
|
||||
|
@ -596,13 +594,13 @@ void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
|
|||
if (!shader)
|
||||
return;
|
||||
assert(shader->get_name() == "mm_gouraud");
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Transform3d view_model_matrix = camera.get_view_matrix() * matrix;
|
||||
shader->set_uniform("view_model_matrix", view_model_matrix);
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
for (size_t color_idx = 0; color_idx < m_gizmo_scene.triangle_indices.size(); ++color_idx) {
|
||||
if (m_gizmo_scene.has_VBOs(color_idx)) {
|
||||
|
@ -616,11 +614,7 @@ void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
|
|||
}
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_paint_contour(matrix);
|
||||
#else
|
||||
render_paint_contour();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#else
|
||||
if (m_paint_contour.has_VBO()) {
|
||||
ScopeGuard guard_mm_gouraud([shader]() { shader->start_using(); });
|
||||
|
@ -722,14 +716,14 @@ void GLMmSegmentationGizmo3DScene::render(size_t triangle_indices_idx) const
|
|||
assert(this->vertices_VBO_id != 0);
|
||||
assert(this->triangle_indices_VBO_ids[triangle_indices_idx] != 0);
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
GLShaderProgram* shader = wxGetApp().get_current_shader();
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, this->vertices_VBO_id));
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const GLint position_id = shader->get_attrib_location("v_position");
|
||||
if (position_id != -1) {
|
||||
glsafe(::glVertexAttribPointer(position_id, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (GLvoid*)0));
|
||||
|
@ -745,18 +739,18 @@ void GLMmSegmentationGizmo3DScene::render(size_t triangle_indices_idx) const
|
|||
|
||||
// Render using the Vertex Buffer Objects.
|
||||
if (this->triangle_indices_sizes[triangle_indices_idx] > 0) {
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->triangle_indices_VBO_ids[triangle_indices_idx]));
|
||||
glsafe(::glDrawElements(GL_TRIANGLES, GLsizei(this->triangle_indices_sizes[triangle_indices_idx]), GL_UNSIGNED_INT, nullptr));
|
||||
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (position_id != -1)
|
||||
glsafe(::glDisableVertexAttribArray(position_id));
|
||||
#else
|
||||
glsafe(::glDisableClientState(GL_VERTEX_ARRAY));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0));
|
||||
}
|
||||
|
|
|
@ -66,13 +66,13 @@ public:
|
|||
: TriangleSelectorGUI(mesh), m_colors(colors), m_default_volume_color(default_volume_color), m_gizmo_scene(2 * (colors.size() + 1)) {}
|
||||
~TriangleSelectorMmGui() override = default;
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void render(ImGuiWrapper* imgui, const Transform3d& matrix) override;
|
||||
#else
|
||||
// Render current selection. Transformation matrices are supposed
|
||||
// to be already set.
|
||||
void render(ImGuiWrapper* imgui) override;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
private:
|
||||
void update_render_data();
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#include "GLGizmoMove.hpp"
|
||||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
|
@ -173,9 +173,6 @@ void GLGizmoMove3D::on_render()
|
|||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
|
@ -185,7 +182,7 @@ void GLGizmoMove3D::on_render()
|
|||
shader->set_uniform("width", 0.25f);
|
||||
shader->set_uniform("gap_size", 0.0f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// draw axes
|
||||
for (unsigned int i = 0; i < 3; ++i) {
|
||||
|
@ -227,7 +224,6 @@ void GLGizmoMove3D::on_render()
|
|||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
|
@ -237,7 +233,6 @@ void GLGizmoMove3D::on_render()
|
|||
shader->set_uniform("width", 0.5f);
|
||||
shader->set_uniform("gap_size", 0.0f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
render_grabber_connection(m_hover_id);
|
||||
shader->stop_using();
|
||||
|
@ -324,15 +319,6 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
|
|||
m_cone.set_color((!picking && m_hover_id != -1) ? complementary(m_grabbers[axis].color) : m_grabbers[axis].color);
|
||||
shader->start_using();
|
||||
shader->set_uniform("emission_factor", 0.1f);
|
||||
#else
|
||||
m_cone.set_color(-1, (!picking && m_hover_id != -1) ? complementary(m_grabbers[axis].color) : m_grabbers[axis].color);
|
||||
if (!picking) {
|
||||
shader->start_using();
|
||||
shader->set_uniform("emission_factor", 0.1f);
|
||||
}
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
Transform3d view_model_matrix = camera.get_view_matrix() * Geometry::assemble_transform(m_grabbers[axis].center);
|
||||
if (axis == X)
|
||||
|
@ -345,6 +331,12 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
|
|||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
#else
|
||||
m_cone.set_color(-1, (!picking && m_hover_id != -1) ? complementary(m_grabbers[axis].color) : m_grabbers[axis].color);
|
||||
if (!picking) {
|
||||
shader->start_using();
|
||||
shader->set_uniform("emission_factor", 0.1f);
|
||||
}
|
||||
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(m_grabbers[axis].center.x(), m_grabbers[axis].center.y(), m_grabbers[axis].center.z()));
|
||||
if (axis == X)
|
||||
|
@ -354,14 +346,13 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
|
|||
|
||||
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
|
||||
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
m_cone.render();
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (! picking)
|
||||
glsafe(::glPopMatrix());
|
||||
if (!picking)
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->stop_using();
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const
|
|||
if (is_left_handed)
|
||||
glsafe(::glFrontFace(GL_CW));
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Transform3d matrix = camera.get_view_matrix() * trafo_matrix;
|
||||
shader->set_uniform("view_model_matrix", matrix);
|
||||
|
@ -115,7 +115,7 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const
|
|||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glMultMatrixd(trafo_matrix.data()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// For printers with multiple extruders, it is necessary to pass trafo_matrix
|
||||
// to the shader input variable print_box.volume_world_matrix before
|
||||
|
@ -123,13 +123,13 @@ void GLGizmoPainterBase::render_triangles(const Selection& selection) const
|
|||
// wrong transformation matrix is used for "Clipping of view".
|
||||
shader->set_uniform("volume_world_matrix", trafo_matrix);
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_triangle_selectors[mesh_id]->render(m_imgui, trafo_matrix);
|
||||
#else
|
||||
m_triangle_selectors[mesh_id]->render(m_imgui);
|
||||
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (is_left_handed)
|
||||
glsafe(::glFrontFace(GL_CCW));
|
||||
}
|
||||
|
@ -164,14 +164,14 @@ void GLGizmoPainterBase::render_cursor()
|
|||
|
||||
void GLGizmoPainterBase::render_cursor_circle()
|
||||
{
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||
const float zoom = float(camera.get_zoom());
|
||||
const float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
const Size cnv_size = m_parent.get_canvas_size();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const float cnv_width = float(cnv_size.get_width());
|
||||
const float cnv_height = float(cnv_size.get_height());
|
||||
if (cnv_width == 0.0f || cnv_height == 0.0f)
|
||||
|
@ -190,7 +190,7 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||
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());
|
||||
center = center * inv_zoom;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glLineWidth(1.5f));
|
||||
|
@ -201,7 +201,7 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glLoadIdentity());
|
||||
// ensure that the circle is renderered inside the frustrum
|
||||
|
@ -209,7 +209,7 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||
// ensure that the overlay fits the frustrum near z plane
|
||||
const double gui_scale = camera.get_gui_scale();
|
||||
glsafe(::glScaled(gui_scale, gui_scale, 1.0));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glPushAttrib(GL_ENABLE_BIT));
|
||||
|
@ -218,13 +218,8 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||
#endif // !ENABLE_GL_CORE_PROFILE
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (!m_circle.is_initialized() || !m_old_center.isApprox(center) || std::abs(m_old_cursor_radius - radius) > EPSILON) {
|
||||
m_old_cursor_radius = radius;
|
||||
#else
|
||||
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;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_old_center = center;
|
||||
m_circle.reset();
|
||||
|
||||
|
@ -251,10 +246,6 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
|
||||
for (unsigned int i = 0; i < StepsCount; ++i) {
|
||||
#if !ENABLE_GL_CORE_PROFILE
|
||||
const float angle = float(i) * StepSize;
|
||||
#endif // !ENABLE_GL_CORE_PROFILE
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
const float angle_i = float(i) * StepSize;
|
||||
const unsigned int j = (i + 1) % StepsCount;
|
||||
|
@ -264,16 +255,11 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||
init_data.add_vertex(Vec4f(v_i.x(), v_i.y(), 0.0f, perimeter));
|
||||
perimeter += (v_j - v_i).norm();
|
||||
init_data.add_vertex(Vec4f(v_j.x(), v_j.y(), 0.0f, perimeter));
|
||||
#else
|
||||
init_data.add_vertex(Vec2f(2.0f * ((center.x() + ::cos(angle) * radius) * cnv_inv_width - 0.5f),
|
||||
-2.0f * ((center.y() + ::sin(angle) * radius) * cnv_inv_height - 0.5f)));
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#else
|
||||
init_data.add_vertex(Vec2f(center.x() + ::cos(angle) * m_cursor_radius, center.y() + ::sin(angle) * m_cursor_radius));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
init_data.add_line(i * 2 + 0, i * 2 + 1);
|
||||
#else
|
||||
const float angle = float(i) * StepSize;
|
||||
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)));
|
||||
init_data.add_index(i);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
}
|
||||
|
@ -288,7 +274,6 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
shader->set_uniform("view_model_matrix", Transform3d::Identity());
|
||||
shader->set_uniform("projection_matrix", Transform3d::Identity());
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
|
@ -298,7 +283,6 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||
shader->set_uniform("dash_size", 0.01f);
|
||||
shader->set_uniform("gap_size", 0.0075f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_circle.render();
|
||||
shader->stop_using();
|
||||
}
|
||||
|
@ -312,9 +296,9 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||
#if !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glPopAttrib());
|
||||
#endif // !ENABLE_GL_CORE_PROFILE
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
}
|
||||
|
||||
|
@ -341,17 +325,17 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
|
|||
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();
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glMultMatrixd(trafo.data()));
|
||||
// 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(::glMultMatrixd(complete_scaling_matrix_inverse.data()));
|
||||
glsafe(::glScaled(m_cursor_radius, m_cursor_radius, m_cursor_radius));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
if (is_left_handed)
|
||||
glFrontFace(GL_CW);
|
||||
glsafe(::glFrontFace(GL_CW));
|
||||
|
||||
ColorRGBA render_color = { 0.0f, 0.0f, 0.0f, 0.25f };
|
||||
if (m_button_down == Button::Left)
|
||||
|
@ -361,7 +345,6 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
|
|||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->start_using();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
Transform3d view_model_matrix = camera.get_view_matrix() * trafo *
|
||||
Geometry::assemble_transform(m_rr.hit.cast<double>()) * complete_scaling_matrix_inverse *
|
||||
|
@ -369,7 +352,6 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
|
|||
|
||||
shader->set_uniform("view_model_matrix", view_model_matrix);
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
assert(s_sphere != nullptr);
|
||||
s_sphere->set_color(render_color);
|
||||
|
@ -385,11 +367,11 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
|
|||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
if (is_left_handed)
|
||||
glFrontFace(GL_CCW);
|
||||
glsafe(::glFrontFace(GL_CCW));
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
|
||||
|
@ -948,11 +930,11 @@ ColorRGBA TriangleSelectorGUI::get_seed_fill_color(const ColorRGBA& base_color)
|
|||
return saturate(base_color, 0.75f);
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void TriangleSelectorGUI::render(ImGuiWrapper* imgui, const Transform3d& matrix)
|
||||
#else
|
||||
void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
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 };
|
||||
|
@ -1003,11 +985,7 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
|||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_paint_contour(matrix);
|
||||
#else
|
||||
render_paint_contour();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#else
|
||||
if (m_paint_contour.has_VBO()) {
|
||||
ScopeGuard guard_gouraud([shader]() { shader->start_using(); });
|
||||
|
@ -1328,11 +1306,9 @@ void TriangleSelectorGUI::render_debug(ImGuiWrapper* imgui)
|
|||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
::glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
|
||||
|
@ -1380,10 +1356,8 @@ void TriangleSelectorGUI::update_paint_contour()
|
|||
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
|
||||
init_data.reserve_vertices(2 * contour_edges.size());
|
||||
init_data.reserve_indices(2 * contour_edges.size());
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
init_data.color = ColorRGBA::WHITE();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
//
|
||||
|
||||
// vertices + indices
|
||||
unsigned int vertices_count = 0;
|
||||
for (const Vec2i& edge : contour_edges) {
|
||||
|
@ -1397,11 +1371,7 @@ void TriangleSelectorGUI::update_paint_contour()
|
|||
m_paint_contour.init_from(std::move(init_data));
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
void TriangleSelectorGUI::render_paint_contour(const Transform3d& matrix)
|
||||
#else
|
||||
void TriangleSelectorGUI::render_paint_contour()
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
{
|
||||
auto* curr_shader = wxGetApp().get_current_shader();
|
||||
if (curr_shader != nullptr)
|
||||
|
@ -1412,11 +1382,9 @@ void TriangleSelectorGUI::render_paint_contour()
|
|||
contour_shader->start_using();
|
||||
|
||||
contour_shader->set_uniform("offset", OpenGLManager::get_gl_info().is_mesa() ? 0.0005 : 0.00001);
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
contour_shader->set_uniform("view_model_matrix", camera.get_view_matrix() * matrix);
|
||||
contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
m_paint_contour.render();
|
||||
contour_shader->stop_using();
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
: TriangleSelector(mesh) {}
|
||||
virtual ~TriangleSelectorGUI() = default;
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
virtual void render(ImGuiWrapper* imgui, const Transform3d& matrix);
|
||||
void render(const Transform3d& matrix) { this->render(nullptr, matrix); }
|
||||
#else
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
// to be already set.
|
||||
virtual void render(ImGuiWrapper *imgui);
|
||||
void render() { this->render(nullptr); }
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
void request_update_render_data() { m_update_render_data = true; }
|
||||
|
||||
|
@ -119,14 +119,10 @@ private:
|
|||
|
||||
protected:
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
GLModel m_paint_contour;
|
||||
GLModel m_paint_contour;
|
||||
|
||||
void update_paint_contour();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
void render_paint_contour(const Transform3d& matrix);
|
||||
#else
|
||||
void render_paint_contour();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#else
|
||||
GLPaintContour m_paint_contour;
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
|
|
@ -168,12 +168,12 @@ void GLGizmoRotate::on_render()
|
|||
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_grabbers.front().matrix = local_transform(selection);
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
transform_to_local(selection);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f));
|
||||
|
@ -187,7 +187,6 @@ void GLGizmoRotate::on_render()
|
|||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Transform3d view_model_matrix = camera.get_view_matrix() * m_grabbers.front().matrix;
|
||||
shader->set_uniform("view_model_matrix", view_model_matrix);
|
||||
|
@ -198,7 +197,6 @@ void GLGizmoRotate::on_render()
|
|||
shader->set_uniform("width", 0.25f);
|
||||
shader->set_uniform("gap_size", 0.0f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
const bool radius_changed = std::abs(m_old_radius - m_radius) > EPSILON;
|
||||
m_old_radius = m_radius;
|
||||
|
@ -240,9 +238,9 @@ void GLGizmoRotate::on_render()
|
|||
render_grabber_extension(box, false);
|
||||
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
void GLGizmoRotate::on_render_for_picking()
|
||||
|
@ -251,12 +249,12 @@ void GLGizmoRotate::on_render_for_picking()
|
|||
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_grabbers.front().matrix = local_transform(selection);
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
transform_to_local(selection);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
||||
render_grabbers_for_picking(box);
|
||||
|
@ -264,9 +262,9 @@ void GLGizmoRotate::on_render_for_picking()
|
|||
render_grabber_extension(box, true);
|
||||
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
void GLGizmoRotate3D::on_render_input_window(float x, float y, float bottom_limit)
|
||||
|
@ -616,7 +614,7 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
|
|||
|
||||
const Vec3d& center = m_grabbers.front().center;
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Transform3d& view_matrix = camera.get_view_matrix();
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
|
@ -634,9 +632,9 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
|
|||
glsafe(::glRotated(90.0, 1.0, 0.0, 0.0));
|
||||
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
|
||||
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_cone.render();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
view_model_matrix = view_matrix * m_grabbers.front().matrix *
|
||||
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));
|
||||
|
@ -651,20 +649,18 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
|
|||
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
|
||||
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
|
||||
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_cone.render();
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (! picking)
|
||||
glsafe(::glPopMatrix());
|
||||
if (!picking)
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->stop_using();
|
||||
}
|
||||
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
Transform3d GLGizmoRotate::local_transform(const Selection& selection) const
|
||||
{
|
||||
Transform3d ret;
|
||||
|
@ -726,7 +722,7 @@ void GLGizmoRotate::transform_to_local(const Selection& selection) const
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
Vec3d GLGizmoRotate::mouse_position_in_local_plane(const Linef3& mouse_ray, const Selection& selection) const
|
||||
{
|
||||
|
|
|
@ -111,11 +111,11 @@ private:
|
|||
void render_grabber_extension(const BoundingBoxf3& box, bool picking);
|
||||
#endif // !ENABLE_GIZMO_GRABBER_REFACTOR
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
Transform3d local_transform(const Selection& selection) const;
|
||||
#else
|
||||
void transform_to_local(const Selection& selection) const;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
// returns the intersection of the mouse ray with the plane perpendicular to the gizmo axis, in local coordinate
|
||||
Vec3d mouse_position_in_local_plane(const Linef3& mouse_ray, const Selection& selection) const;
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#include "GLGizmoScale.hpp"
|
||||
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
|
@ -274,7 +274,6 @@ void GLGizmoScale3D::on_render()
|
|||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
|
@ -284,7 +283,6 @@ void GLGizmoScale3D::on_render()
|
|||
shader->set_uniform("width", 0.25f);
|
||||
shader->set_uniform("gap_size", 0.0f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (m_grabbers[0].enabled && m_grabbers[1].enabled)
|
||||
render_grabbers_connection(0, 1, m_grabbers[0].color);
|
||||
if (m_grabbers[2].enabled && m_grabbers[3].enabled)
|
||||
|
@ -331,7 +329,6 @@ void GLGizmoScale3D::on_render()
|
|||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
|
@ -341,7 +338,6 @@ void GLGizmoScale3D::on_render()
|
|||
shader->set_uniform("width", 0.25f);
|
||||
shader->set_uniform("gap_size", 0.0f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_grabbers_connection(0, 1, m_grabbers[0].color);
|
||||
shader->stop_using();
|
||||
}
|
||||
|
@ -374,7 +370,6 @@ void GLGizmoScale3D::on_render()
|
|||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
|
@ -384,7 +379,6 @@ void GLGizmoScale3D::on_render()
|
|||
shader->set_uniform("width", 0.25f);
|
||||
shader->set_uniform("gap_size", 0.0f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_grabbers_connection(2, 3, m_grabbers[2].color);
|
||||
shader->stop_using();
|
||||
}
|
||||
|
@ -417,7 +411,6 @@ void GLGizmoScale3D::on_render()
|
|||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
|
@ -427,7 +420,6 @@ void GLGizmoScale3D::on_render()
|
|||
shader->set_uniform("width", 0.25f);
|
||||
shader->set_uniform("gap_size", 0.0f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_grabbers_connection(4, 5, m_grabbers[4].color);
|
||||
shader->stop_using();
|
||||
}
|
||||
|
@ -460,7 +452,6 @@ void GLGizmoScale3D::on_render()
|
|||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
|
@ -470,7 +461,6 @@ void GLGizmoScale3D::on_render()
|
|||
shader->set_uniform("width", 0.25f);
|
||||
shader->set_uniform("gap_size", 0.0f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_grabbers_connection(6, 7, m_drag_color);
|
||||
render_grabbers_connection(7, 8, m_drag_color);
|
||||
render_grabbers_connection(8, 9, m_drag_color);
|
||||
|
|
|
@ -738,10 +738,10 @@ void GLGizmoSimplify::on_render()
|
|||
GLModel &glmodel = it->second;
|
||||
|
||||
const Transform3d trafo_matrix = selected_volume->world_matrix();
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glMultMatrixd(trafo_matrix.data()));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
auto* gouraud_shader = wxGetApp().get_shader("gouraud_light");
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
bool depth_test_enabled = ::glIsEnabled(GL_DEPTH_TEST);
|
||||
|
@ -750,13 +750,13 @@ void GLGizmoSimplify::on_render()
|
|||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
gouraud_shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
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("projection_matrix", camera.get_projection_matrix());
|
||||
gouraud_shader->set_uniform("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glmodel.render();
|
||||
gouraud_shader->stop_using();
|
||||
|
||||
|
@ -764,21 +764,21 @@ void GLGizmoSimplify::on_render()
|
|||
auto *contour_shader = wxGetApp().get_shader("mm_contour");
|
||||
contour_shader->start_using();
|
||||
contour_shader->set_uniform("offset", OpenGLManager::get_gl_info().is_mesa() ? 0.0005 : 0.00001);
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
contour_shader->set_uniform("view_model_matrix", view_model_matrix);
|
||||
contour_shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
const ColorRGBA color = glmodel.get_color();
|
||||
glmodel.set_color(ColorRGBA::WHITE());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glLineWidth(1.0f));
|
||||
#endif // !ENABLE_GL_CORE_PROFILE
|
||||
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_LINE));
|
||||
glmodel.render();
|
||||
glsafe(::glPolygonMode(GL_FRONT_AND_BACK, GL_FILL));
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glmodel.set_color(color);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
contour_shader->stop_using();
|
||||
}
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
|
@ -787,9 +787,9 @@ void GLGizmoSimplify::on_render()
|
|||
#else
|
||||
glsafe(::glPopAttrib());
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
|||
const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin());
|
||||
Geometry::Transformation transformation(vol->get_instance_transformation().get_matrix() * vol->get_volume_transformation().get_matrix());
|
||||
const Transform3d& instance_scaling_matrix_inverse = transformation.get_matrix(true, true, false, true).inverse();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Transform3d instance_matrix = Geometry::assemble_transform(m_c->selection_info()->get_sla_shift() * Vec3d::UnitZ()) * transformation.get_matrix();
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Transform3d& view_matrix = camera.get_view_matrix();
|
||||
|
@ -162,7 +162,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
|||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(0.0, 0.0, z_shift));
|
||||
glsafe(::glMultMatrixd(instance_matrix.data()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
ColorRGBA render_color;
|
||||
for (size_t i = 0; i < cache_size; ++i) {
|
||||
|
@ -206,16 +206,16 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
|||
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.
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Transform3d support_matrix = Geometry::assemble_transform(support_point.pos.cast<double>()) * instance_scaling_matrix_inverse;
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(support_point.pos.x(), support_point.pos.y(), support_point.pos.z()));
|
||||
glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
if (vol->is_left_handed())
|
||||
glFrontFace(GL_CW);
|
||||
glsafe(::glFrontFace(GL_CW));
|
||||
|
||||
// Matrices set, we can render the point mark now.
|
||||
// If in editing mode, we'll also render a cone pointing to the sphere.
|
||||
|
@ -229,7 +229,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
|||
const Eigen::AngleAxisd aa(q);
|
||||
const double cone_radius = 0.25; // mm
|
||||
const double cone_height = 0.75;
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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(),
|
||||
Vec3d(PI, 0.0, 0.0), Vec3d(cone_radius, cone_radius, cone_height));
|
||||
|
@ -242,15 +242,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(::glRotated(180., 1., 0., 0.));
|
||||
glsafe(::glScaled(cone_radius, cone_radius, cone_height));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_cone.render();
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
const double radius = (double)support_point.head_front_radius * RenderPointScale;
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Transform3d view_model_matrix = view_matrix * instance_matrix * support_matrix *
|
||||
Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), radius * Vec3d::Ones());
|
||||
|
||||
|
@ -259,18 +259,18 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
|||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glScaled(radius, radius, radius));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_sphere.render();
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
if (vol->is_left_handed())
|
||||
glFrontFace(GL_CCW);
|
||||
glsafe(::glFrontFace(GL_CCW));
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
// Now render the drain holes:
|
||||
|
@ -287,23 +287,23 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
|
|||
if (is_mesh_point_clipped(drain_hole.pos.cast<double>()))
|
||||
continue;
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Transform3d hole_matrix = Geometry::assemble_transform(drain_hole.pos.cast<double>()) * instance_scaling_matrix_inverse;
|
||||
#else
|
||||
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslatef(drain_hole.pos.x(), drain_hole.pos.y(), drain_hole.pos.z()));
|
||||
glsafe(::glMultMatrixd(instance_scaling_matrix_inverse.data()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
if (vol->is_left_handed())
|
||||
glFrontFace(GL_CW);
|
||||
glsafe(::glFrontFace(GL_CW));
|
||||
|
||||
// Matrices set, we can render the point mark now.
|
||||
Eigen::Quaterniond q;
|
||||
q.setFromTwoVectors(Vec3d::UnitZ(), instance_scaling_matrix_inverse * (-drain_hole.normal).cast<double>());
|
||||
const Eigen::AngleAxisd aa(q);
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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));
|
||||
|
||||
|
@ -313,20 +313,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(::glTranslated(0., 0., -drain_hole.height));
|
||||
glsafe(::glScaled(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_cylinder.render();
|
||||
|
||||
if (vol->is_left_handed())
|
||||
glFrontFace(GL_CCW);
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glFrontFace(GL_CCW));
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
}
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -213,10 +213,8 @@ void InstancesHider::render_cut() const
|
|||
else
|
||||
clipper->set_limiting_plane(ClippingPlane::ClipsNothing());
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPushMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPushMatrix());
|
||||
if (mv->is_model_part())
|
||||
glsafe(::glColor3f(0.8f, 0.3f, 0.0f));
|
||||
else {
|
||||
|
@ -241,9 +239,9 @@ void InstancesHider::render_cut() const
|
|||
#else
|
||||
glsafe(::glPopAttrib());
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
++clipper_id;
|
||||
}
|
||||
|
@ -436,18 +434,14 @@ void ObjectClipper::render_cut() const
|
|||
clipper->set_plane(*m_clp);
|
||||
clipper->set_transformation(trafo);
|
||||
clipper->set_limiting_plane(ClippingPlane(Vec3d::UnitZ(), -SINKING_Z_THRESHOLD));
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPushMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
clipper->render_cut({ 1.0f, 0.37f, 0.0f, 1.0f });
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glColor3f(1.0f, 0.37f, 0.0f));
|
||||
clipper->render_cut();
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
++clipper_id;
|
||||
}
|
||||
|
@ -557,18 +551,14 @@ void SupportsClipper::render_cut() const
|
|||
m_clipper->set_plane(*ocl->get_clipping_plane());
|
||||
m_clipper->set_transformation(supports_trafo);
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPushMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_clipper->render_cut({ 1.0f, 0.f, 0.37f, 1.0f });
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glColor3f(1.0f, 0.f, 0.37f));
|
||||
m_clipper->render_cut();
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ bool GLGizmosManager::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
bool GLGizmosManager::init_arrow(const std::string& filename)
|
||||
{
|
||||
if (m_arrow_texture.get_id() != 0)
|
||||
|
@ -149,7 +149,7 @@ bool GLGizmosManager::init_arrow(const BackgroundTexture::Metadata & arrow_textu
|
|||
|
||||
return res;
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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();
|
||||
|
@ -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 } });
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void GLGizmosManager::render_arrow(const GLCanvas3D& parent, EType highlighted_type) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void GLGizmosManager::do_render_overlay() const
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
float GLGizmosManager::get_scaled_total_height() const
|
||||
{
|
||||
|
|
|
@ -105,11 +105,11 @@ private:
|
|||
GLTexture m_icons_texture;
|
||||
bool m_icons_texture_dirty;
|
||||
BackgroundTexture m_background_texture;
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
GLTexture m_arrow_texture;
|
||||
#else
|
||||
BackgroundTexture m_arrow_texture;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
Layout m_layout;
|
||||
EType m_current;
|
||||
EType m_hover;
|
||||
|
@ -137,11 +137,11 @@ public:
|
|||
|
||||
bool init();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
bool init_arrow(const std::string& filename);
|
||||
#else
|
||||
bool init_arrow(const BackgroundTexture::Metadata& arrow_texture);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
template<class Archive>
|
||||
void load(Archive& ar)
|
||||
|
@ -242,11 +242,11 @@ private:
|
|||
bool alt_down = false,
|
||||
bool control_down = false);
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void render_background(float left, float top, float right, float bottom, float border_w, float border_h) const;
|
||||
#else
|
||||
void render_background(float left, float top, float right, float bottom, float border) const;
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
void do_render_overlay() const;
|
||||
|
||||
|
|
|
@ -32,9 +32,7 @@
|
|||
#include "I18N.hpp"
|
||||
#include "Search.hpp"
|
||||
#include "BitmapCache.hpp"
|
||||
#if ENABLE_GL_IMGUI_SHADERS
|
||||
#include "GUI_App.hpp"
|
||||
#endif // ENABLE_GL_IMGUI_SHADERS
|
||||
|
||||
#include "../Utils/MacDarkMode.hpp"
|
||||
|
||||
|
|
|
@ -8,11 +8,9 @@
|
|||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#include "slic3r/GUI/Camera.hpp"
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
|
@ -90,11 +88,9 @@ void MeshClipper::render_cut()
|
|||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||
if (shader != nullptr) {
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_model.set_color(color);
|
||||
m_model.render();
|
||||
shader->stop_using();
|
||||
|
|
|
@ -1289,30 +1289,25 @@ void Selection::render_center(bool gizmo_is_dragging)
|
|||
|
||||
glsafe(::glDisable(GL_DEPTH_TEST));
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
Transform3d view_model_matrix = camera.get_view_matrix() * Geometry::assemble_transform(center);
|
||||
|
||||
shader->set_uniform("view_model_matrix", view_model_matrix);
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
m_vbo_sphere.set_color(ColorRGBA::WHITE());
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glTranslated(center.x(), center.y(), center.z()));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_vbo_sphere.set_color(ColorRGBA::WHITE());
|
||||
#else
|
||||
m_vbo_sphere.set_color(-1, ColorRGBA::WHITE());
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_vbo_sphere.render();
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_vbo_sphere.render();
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->stop_using();
|
||||
#else
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
#endif // ENABLE_RENDER_SELECTION_CENTER
|
||||
|
@ -1343,27 +1338,27 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
|
|||
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Transform3d base_matrix = Geometry::assemble_transform(get_bounding_box().center());
|
||||
Transform3d orient_matrix = Transform3d::Identity();
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
if (!boost::starts_with(sidebar_field, "layer")) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->set_uniform("emission_factor", 0.05f);
|
||||
#else
|
||||
const Vec3d& center = get_bounding_box().center();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (is_single_full_instance() && !wxGetApp().obj_manipul()->get_world_coordinates()) {
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glTranslated(center.x(), center.y(), center.z()));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (!boost::starts_with(sidebar_field, "position")) {
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
Transform3d orient_matrix = Transform3d::Identity();
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (boost::starts_with(sidebar_field, "scale"))
|
||||
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
|
||||
else if (boost::starts_with(sidebar_field, "rotation")) {
|
||||
|
@ -1377,27 +1372,27 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
|
|||
orient_matrix.rotate(Eigen::AngleAxisd(rotation.z(), Vec3d::UnitZ()));
|
||||
}
|
||||
}
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glMultMatrixd(orient_matrix.data()));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
}
|
||||
else if (is_single_volume() || is_single_modifier()) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
|
||||
#else
|
||||
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);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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);
|
||||
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
glsafe(::glMultMatrixd(orient_matrix.data()));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
else {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (requires_local_axes())
|
||||
orient_matrix = (*m_volumes)[*m_list.begin()]->get_instance_transformation().get_matrix(true, false, true, true);
|
||||
#else
|
||||
|
@ -1406,16 +1401,14 @@ 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);
|
||||
glsafe(::glMultMatrixd(orient_matrix.data()));
|
||||
}
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (!boost::starts_with(sidebar_field, "layer"))
|
||||
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
if (boost::starts_with(sidebar_field, "position"))
|
||||
render_sidebar_position_hints(sidebar_field, *shader, base_matrix * orient_matrix);
|
||||
else if (boost::starts_with(sidebar_field, "rotation"))
|
||||
|
@ -1435,11 +1428,9 @@ void Selection::render_sidebar_hints(const std::string& sidebar_field)
|
|||
render_sidebar_layers_hints(sidebar_field);
|
||||
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
#if !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
if (!boost::starts_with(sidebar_field, "layer"))
|
||||
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
shader->stop_using();
|
||||
}
|
||||
|
||||
|
@ -2023,7 +2014,6 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con
|
|||
return;
|
||||
|
||||
shader->start_using();
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
|
@ -2033,7 +2023,6 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con
|
|||
shader->set_uniform("width", 1.5f);
|
||||
shader->set_uniform("gap_size", 0.0f);
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_box.set_color(to_rgba(color));
|
||||
m_box.render();
|
||||
shader->stop_using();
|
||||
|
@ -2081,46 +2070,34 @@ static ColorRGBA get_color(Axis axis)
|
|||
return AXES_COLOR[axis];
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void Selection::render_sidebar_position_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix)
|
||||
#else
|
||||
void Selection::render_sidebar_position_hints(const std::string& sidebar_field)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Transform3d view_matrix = camera.get_view_matrix() * matrix;
|
||||
shader.set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
if (boost::ends_with(sidebar_field, "x")) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
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("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
#else
|
||||
glsafe(::glRotated(-90.0, 0.0, 0.0, 1.0));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_arrow.set_color(get_color(X));
|
||||
m_arrow.render();
|
||||
}
|
||||
else if (boost::ends_with(sidebar_field, "y")) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
shader.set_uniform("view_model_matrix", view_matrix);
|
||||
shader.set_uniform("normal_matrix", (Matrix3d)view_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_arrow.set_color(get_color(Y));
|
||||
m_arrow.render();
|
||||
}
|
||||
}
|
||||
else if (boost::ends_with(sidebar_field, "z")) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
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("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
#else
|
||||
glsafe(::glRotated(90.0, 1.0, 0.0, 0.0));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_arrow.set_color(get_color(Z));
|
||||
m_arrow.render();
|
||||
}
|
||||
|
@ -2142,14 +2119,13 @@ void Selection::render_sidebar_position_hints(const std::string& sidebar_field)
|
|||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix)
|
||||
#else
|
||||
void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
auto render_sidebar_rotation_hint = [this](GLShaderProgram& shader, const Transform3d& matrix) {
|
||||
Transform3d view_model_matrix = matrix;
|
||||
shader.set_uniform("view_model_matrix", view_model_matrix);
|
||||
|
@ -2164,45 +2140,20 @@ void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field)
|
|||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Transform3d view_matrix = camera.get_view_matrix() * matrix;
|
||||
shader.set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#else
|
||||
auto render_sidebar_rotation_hint = [this]() {
|
||||
m_curved_arrow.render();
|
||||
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
|
||||
m_curved_arrow.render();
|
||||
};
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
|
||||
if (boost::ends_with(sidebar_field, "x")) {
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glRotated(90.0, 0.0, 1.0, 0.0));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_curved_arrow.set_color(get_color(X));
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_sidebar_rotation_hint(shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitY()));
|
||||
#else
|
||||
render_sidebar_rotation_hint();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
else if (boost::ends_with(sidebar_field, "y")) {
|
||||
#if !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
|
||||
#endif // !ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
m_curved_arrow.set_color(get_color(Y));
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_sidebar_rotation_hint(shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitX()));
|
||||
#else
|
||||
render_sidebar_rotation_hint();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
else if (boost::ends_with(sidebar_field, "z")) {
|
||||
m_curved_arrow.set_color(get_color(Z));
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
render_sidebar_rotation_hint(shader, view_matrix);
|
||||
#else
|
||||
render_sidebar_rotation_hint();
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
}
|
||||
#else
|
||||
#else
|
||||
auto render_sidebar_rotation_hint = [this]() {
|
||||
m_curved_arrow.render();
|
||||
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
|
||||
|
@ -2226,93 +2177,86 @@ void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field)
|
|||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void Selection::render_sidebar_scale_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix)
|
||||
#else
|
||||
void Selection::render_sidebar_scale_hints(const std::string& sidebar_field)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
const bool uniform_scale = requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis, GLShaderProgram& shader, const Transform3d& matrix) {
|
||||
#else
|
||||
auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis) {
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis, GLShaderProgram& shader, const Transform3d& matrix) {
|
||||
m_arrow.set_color(uniform_scale ? UNIFORM_SCALE_COLOR : get_color(axis));
|
||||
#else
|
||||
m_arrow.set_color(-1, uniform_scale ? UNIFORM_SCALE_COLOR : get_color(axis));
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
Transform3d view_model_matrix = matrix * Geometry::assemble_transform(5.0 * Vec3d::UnitY());
|
||||
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());
|
||||
#else
|
||||
auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis) {
|
||||
m_arrow.set_color(-1, uniform_scale ? UNIFORM_SCALE_COLOR : get_color(axis));
|
||||
GLShaderProgram* shader = wxGetApp().get_current_shader();
|
||||
if (shader != nullptr)
|
||||
shader->set_uniform("emission_factor", 0.0f);
|
||||
|
||||
glsafe(::glTranslated(0.0, 5.0, 0.0));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_arrow.render();
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
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("normal_matrix", (Matrix3d)view_model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose());
|
||||
#else
|
||||
glsafe(::glTranslated(0.0, -10.0, 0.0));
|
||||
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
m_arrow.render();
|
||||
};
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
const Transform3d view_matrix = camera.get_view_matrix() * matrix;
|
||||
shader.set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
if (boost::ends_with(sidebar_field, "x") || uniform_scale) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
render_sidebar_scale_hint(X, shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), -0.5 * PI * Vec3d::UnitZ()));
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glRotated(-90.0, 0.0, 0.0, 1.0));
|
||||
render_sidebar_scale_hint(X);
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
if (boost::ends_with(sidebar_field, "y") || uniform_scale) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
render_sidebar_scale_hint(Y, shader, view_matrix);
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
render_sidebar_scale_hint(Y);
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
|
||||
if (boost::ends_with(sidebar_field, "z") || uniform_scale) {
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
render_sidebar_scale_hint(Z, shader, view_matrix * Geometry::assemble_transform(Vec3d::Zero(), 0.5 * PI * Vec3d::UnitX()));
|
||||
#else
|
||||
glsafe(::glPushMatrix());
|
||||
glsafe(::glRotated(90.0, 1.0, 0.0, 0.0));
|
||||
render_sidebar_scale_hint(Z);
|
||||
glsafe(::glPopMatrix());
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
void Selection::render_sidebar_layers_hints(const std::string& sidebar_field, GLShaderProgram& shader)
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void Selection::render_sidebar_layers_hints(const std::string & sidebar_field, GLShaderProgram & shader)
|
||||
#else
|
||||
void Selection::render_sidebar_layers_hints(const std::string& sidebar_field)
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
void Selection::render_sidebar_layers_hints(const std::string & sidebar_field)
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
{
|
||||
static const float Margin = 10.0f;
|
||||
|
||||
|
@ -2410,11 +2354,9 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field)
|
|||
m_planes.models[1].init_from(std::move(init_data));
|
||||
}
|
||||
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
||||
shader.set_uniform("view_model_matrix", camera.get_view_matrix());
|
||||
shader.set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||
#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].render();
|
||||
|
|
|
@ -372,21 +372,18 @@ private:
|
|||
void render_synchronized_volumes();
|
||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
void render_bounding_box(const BoundingBoxf3& box, const ColorRGB& color);
|
||||
#else
|
||||
void render_selected_volumes() const;
|
||||
void render_bounding_box(const BoundingBoxf3& box, float* color) const;
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
#if ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
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_scale_hints(const std::string& sidebar_field, GLShaderProgram& shader, const Transform3d& matrix);
|
||||
void render_sidebar_layers_hints(const std::string& sidebar_field, GLShaderProgram& shader);
|
||||
#else
|
||||
void render_selected_volumes() const;
|
||||
void render_bounding_box(const BoundingBoxf3& box, float* color) const;
|
||||
void render_sidebar_position_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_layers_hints(const std::string& sidebar_field);
|
||||
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
|
||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||
|
||||
public:
|
||||
enum SyncRotationType {
|
||||
|
|
Loading…
Add table
Reference in a new issue