From 77857f7292d9abf648010045efcd6e27fb09ea34 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 26 Jul 2019 09:45:22 +0200 Subject: [PATCH] Refactoring into rendering pipeline --- src/slic3r/GUI/3DBed.cpp | 22 +++++++++------------- src/slic3r/GUI/3DBed.hpp | 2 +- src/slic3r/GUI/GLCanvas3D.cpp | 16 +--------------- src/slic3r/GUI/GLCanvas3D.hpp | 1 - 4 files changed, 11 insertions(+), 30 deletions(-) diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp index a402fa82d4..97e200b38e 100644 --- a/src/slic3r/GUI/3DBed.cpp +++ b/src/slic3r/GUI/3DBed.cpp @@ -266,6 +266,8 @@ void Bed3D::render(GLCanvas3D& canvas, float theta, float scale_factor) const { m_scale_factor = scale_factor; + render_axes(); + switch (m_type) { case MK2: @@ -292,12 +294,6 @@ void Bed3D::render(GLCanvas3D& canvas, float theta, float scale_factor) const } } -void Bed3D::render_axes() const -{ - if (!m_shape.empty()) - m_axes.render(); -} - void Bed3D::calc_bounding_boxes() const { m_bounding_box = BoundingBoxf3(); @@ -393,6 +389,12 @@ Bed3D::EType Bed3D::detect_type(const Pointfs& shape) const return type; } +void Bed3D::render_axes() const +{ + if (!m_shape.empty()) + m_axes.render(); +} + void Bed3D::render_prusa(GLCanvas3D& canvas, const std::string& key, bool bottom) const { if (!bottom) @@ -598,9 +600,7 @@ void Bed3D::render_default(bool bottom) const { bool has_model = !m_model.get_filename().empty(); - glsafe(::glEnable(GL_LIGHTING)); - glsafe(::glDisable(GL_DEPTH_TEST)); - + glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_BLEND)); glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); @@ -615,11 +615,7 @@ void Bed3D::render_default(bool bottom) const glsafe(::glDrawArrays(GL_TRIANGLES, 0, (GLsizei)triangles_vcount)); } - glsafe(::glDisable(GL_LIGHTING)); - // draw grid - // we need depth test for grid, otherwise it would disappear when looking the object from below - glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glLineWidth(3.0f * m_scale_factor)); if (has_model && !bottom) glsafe(::glColor4f(0.75f, 0.75f, 0.75f, 1.0f)); diff --git a/src/slic3r/GUI/3DBed.hpp b/src/slic3r/GUI/3DBed.hpp index a3e4bcf801..c9a30e6ec2 100644 --- a/src/slic3r/GUI/3DBed.hpp +++ b/src/slic3r/GUI/3DBed.hpp @@ -111,13 +111,13 @@ public: Point point_projection(const Point& point) const; void render(GLCanvas3D& canvas, float theta, float scale_factor) const; - void render_axes() const; private: void calc_bounding_boxes() const; void calc_triangles(const ExPolygon& poly); void calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox); EType detect_type(const Pointfs& shape) const; + void render_axes() const; void render_prusa(GLCanvas3D& canvas, const std::string& key, bool bottom) const; void render_texture(const std::string& filename, bool bottom, GLCanvas3D& canvas) const; void render_model(const std::string& filename) const; diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index b072efd988..118c4802ae 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1561,19 +1561,10 @@ void GLCanvas3D::render() glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); _render_background(); - // textured bed needs to be rendered after objects if the texture is transparent - bool early_bed_render = m_bed.is_custom() || (theta <= 90.0f); - if (early_bed_render) - _render_bed(theta); - _render_objects(); _render_sla_slices(); _render_selection(); - - _render_axes(); - - if (!early_bed_render) - _render_bed(theta); + _render_bed(theta); #if ENABLE_RENDER_SELECTION_CENTER _render_selection_center(); @@ -3906,11 +3897,6 @@ void GLCanvas3D::_render_bed(float theta) const m_bed.render(const_cast(*this), theta, scale_factor); } -void GLCanvas3D::_render_axes() const -{ - m_bed.render_axes(); -} - void GLCanvas3D::_render_objects() const { if (m_volumes.empty()) diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index fd60fcabc8..c9803f9db8 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -662,7 +662,6 @@ private: void _rectangular_selection_picking_pass() const; void _render_background() const; void _render_bed(float theta) const; - void _render_axes() const; void _render_objects() const; void _render_selection() const; #if ENABLE_RENDER_SELECTION_CENTER