From 58701b237d233f2b0517106c7ce3a4f10db55873 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 15 Mar 2022 09:05:16 +0100 Subject: [PATCH] Tech ENABLE_GL_SHADERS_ATTRIBUTES - Fixed rendering of bed texture in thumbnails --- src/slic3r/GUI/3DBed.cpp | 15 +++++++++++---- src/slic3r/GUI/3DBed.hpp | 8 +++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp index 177c508ad..f3176d2c7 100644 --- a/src/slic3r/GUI/3DBed.cpp +++ b/src/slic3r/GUI/3DBed.cpp @@ -515,7 +515,7 @@ void Bed3D::render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, co render_model(view_matrix, projection_matrix); if (show_texture) - render_texture(bottom, canvas); + render_texture(bottom, canvas, view_matrix, projection_matrix); } #else void Bed3D::render_system(GLCanvas3D& canvas, bool bottom, bool show_texture) @@ -528,7 +528,11 @@ void Bed3D::render_system(GLCanvas3D& canvas, bool bottom, bool show_texture) } #endif // ENABLE_GL_SHADERS_ATTRIBUTES +#if ENABLE_GL_SHADERS_ATTRIBUTES +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 { if (m_texture_filename.empty()) { m_texture.reset(); @@ -600,9 +604,8 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) 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()); + 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")); @@ -766,7 +769,11 @@ void Bed3D::render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bo #endif // ENABLE_GL_SHADERS_ATTRIBUTES if (show_texture) +#if ENABLE_GL_SHADERS_ATTRIBUTES + render_texture(bottom, canvas, view_matrix, projection_matrix); +#else render_texture(bottom, canvas); +#endif // ENABLE_GL_SHADERS_ATTRIBUTES } void Bed3D::render_default(bool bottom, bool picking) diff --git a/src/slic3r/GUI/3DBed.hpp b/src/slic3r/GUI/3DBed.hpp index de4fa99cf..167577882 100644 --- a/src/slic3r/GUI/3DBed.hpp +++ b/src/slic3r/GUI/3DBed.hpp @@ -168,14 +168,12 @@ private: void render_axes(); #if ENABLE_GL_SHADERS_ATTRIBUTES void render_system(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture); -#else - void render_system(GLCanvas3D& canvas, bool bottom, bool show_texture); -#endif // ENABLE_GL_SHADERS_ATTRIBUTES - void render_texture(bool bottom, GLCanvas3D& canvas); -#if ENABLE_GL_SHADERS_ATTRIBUTES + 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); void render_custom(GLCanvas3D& canvas, const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool show_texture, bool picking); #else + void render_system(GLCanvas3D& canvas, bool bottom, bool show_texture); + void render_texture(bool bottom, GLCanvas3D& canvas); void render_model(); void render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bool picking); #endif // ENABLE_GL_SHADERS_ATTRIBUTES