Tech ENABLE_GL_SHADERS_ATTRIBUTES - Fixed rendering of default bed in thumbnails

This commit is contained in:
enricoturri1966 2022-03-15 09:16:06 +01:00
parent 58701b237d
commit 568bd39c5a
2 changed files with 37 additions and 4 deletions

View File

@ -536,7 +536,11 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas)
{
if (m_texture_filename.empty()) {
m_texture.reset();
#if ENABLE_GL_SHADERS_ATTRIBUTES
render_default(bottom, false, view_matrix, projection_matrix);
#else
render_default(bottom, false);
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
return;
}
@ -549,7 +553,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
render_default(bottom, false, view_matrix, projection_matrix);
#else
render_default(bottom, false);
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
return;
}
canvas.request_extra_frame();
@ -557,7 +565,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
render_default(bottom, false, view_matrix, projection_matrix);
#else
render_default(bottom, false);
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
return;
}
}
@ -565,7 +577,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
render_default(bottom, false, view_matrix, projection_matrix);
#else
render_default(bottom, false);
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
return;
}
canvas.request_extra_frame();
@ -573,12 +589,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
render_default(bottom, false, view_matrix, projection_matrix);
#else
render_default(bottom, false);
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
return;
}
}
else {
#if ENABLE_GL_SHADERS_ATTRIBUTES
render_default(bottom, false, view_matrix, projection_matrix);
#else
render_default(bottom, false);
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
return;
}
}
@ -757,7 +781,11 @@ void Bed3D::render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bo
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
{
if (m_texture_filename.empty() && m_model_filename.empty()) {
#if ENABLE_GL_SHADERS_ATTRIBUTES
render_default(bottom, picking, view_matrix, projection_matrix);
#else
render_default(bottom, picking);
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
return;
}
@ -776,7 +804,11 @@ void Bed3D::render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture, bo
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
}
#if ENABLE_GL_SHADERS_ATTRIBUTES
void Bed3D::render_default(bool bottom, bool picking, const Transform3d& view_matrix, const Transform3d& projection_matrix)
#else
void Bed3D::render_default(bool bottom, bool picking)
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
{
m_texture.reset();
@ -793,9 +825,8 @@ void Bed3D::render_default(bool bottom, bool picking)
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
glsafe(::glEnable(GL_DEPTH_TEST));

View File

@ -171,13 +171,15 @@ private:
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);
void render_default(bool bottom, bool picking, const Transform3d& view_matrix, const Transform3d& projection_matrix);
#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
void render_default(bool bottom, bool picking);
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
#if !ENABLE_LEGACY_OPENGL_REMOVAL
void release_VBOs();
#endif // !ENABLE_LEGACY_OPENGL_REMOVAL