mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 19:33:47 +00:00
Fix black bed texture if svg file (#11166)
* Fix blank bed texture if svg file * Refresh scene once the texture compression is completed
This commit is contained in:
@@ -3309,6 +3309,7 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
|
|||||||
bool imgui_requires_extra_frame = wxGetApp().imgui()->requires_extra_frame();
|
bool imgui_requires_extra_frame = wxGetApp().imgui()->requires_extra_frame();
|
||||||
m_dirty |= imgui_requires_extra_frame;
|
m_dirty |= imgui_requires_extra_frame;
|
||||||
#endif // ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
|
#endif // ENABLE_ENHANCED_IMGUI_SLIDER_FLOAT
|
||||||
|
m_dirty |= GLTexture::Compressor::has_compressed_texture_to_refresh();
|
||||||
|
|
||||||
if (!m_dirty)
|
if (!m_dirty)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ void GLTexture::Compressor::send_compressed_data_to_gpu()
|
|||||||
this->reset();
|
this->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::atomic<bool> GLTexture::Compressor::m_dirty = false;
|
||||||
|
|
||||||
void GLTexture::Compressor::compress()
|
void GLTexture::Compressor::compress()
|
||||||
{
|
{
|
||||||
// reference: https://github.com/Cyan4973/RygsDXTc
|
// reference: https://github.com/Cyan4973/RygsDXTc
|
||||||
@@ -123,6 +125,11 @@ void GLTexture::Compressor::compress()
|
|||||||
level.src_data.clear();
|
level.src_data.clear();
|
||||||
++ m_num_levels_compressed;
|
++ m_num_levels_compressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Trigger an idle event to refresh the scene once the texture data is ready
|
||||||
|
// This fixes the issue that the bed texture is black after switching printer model until mouse moves to the 3d scene
|
||||||
|
m_dirty = true;
|
||||||
|
wxWakeUpIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLTexture::Quad_UVs GLTexture::FullTextureUVs = { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 0.0f, 0.0f } };
|
GLTexture::Quad_UVs GLTexture::FullTextureUVs = { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 0.0f, 0.0f } };
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace GUI {
|
|||||||
|
|
||||||
class GLTexture
|
class GLTexture
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
class Compressor
|
class Compressor
|
||||||
{
|
{
|
||||||
struct Level
|
struct Level
|
||||||
@@ -39,6 +41,8 @@ namespace GUI {
|
|||||||
// This atomic also works as a memory barrier for synchronizing results of the worker thread with the calling thread.
|
// This atomic also works as a memory barrier for synchronizing results of the worker thread with the calling thread.
|
||||||
std::atomic<unsigned int> m_num_levels_compressed;
|
std::atomic<unsigned int> m_num_levels_compressed;
|
||||||
|
|
||||||
|
static std::atomic<bool> m_dirty;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Compressor(GLTexture& texture) : m_texture(texture), m_abort_compressing(false), m_num_levels_compressed(0) {}
|
explicit Compressor(GLTexture& texture) : m_texture(texture), m_abort_compressing(false), m_num_levels_compressed(0) {}
|
||||||
~Compressor() { reset(); }
|
~Compressor() { reset(); }
|
||||||
@@ -53,11 +57,12 @@ namespace GUI {
|
|||||||
void send_compressed_data_to_gpu();
|
void send_compressed_data_to_gpu();
|
||||||
bool all_compressed_data_sent_to_gpu() const { return m_levels.empty(); }
|
bool all_compressed_data_sent_to_gpu() const { return m_levels.empty(); }
|
||||||
|
|
||||||
|
static bool has_compressed_texture_to_refresh() { return m_dirty.exchange(false); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void compress();
|
void compress();
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
|
||||||
enum ECompressionType : unsigned char
|
enum ECompressionType : unsigned char
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "Tab.hpp"
|
#include "Tab.hpp"
|
||||||
#include "format.hpp"
|
#include "format.hpp"
|
||||||
#include "slic3r/GUI/GUI.hpp"
|
#include "slic3r/GUI/GUI.hpp"
|
||||||
|
#include "slic3r/Utils/FileHelp.hpp"
|
||||||
#include <imgui/imgui_internal.h>
|
#include <imgui/imgui_internal.h>
|
||||||
#include <wx/dcgraph.h>
|
#include <wx/dcgraph.h>
|
||||||
using boost::optional;
|
using boost::optional;
|
||||||
@@ -5563,8 +5564,10 @@ void PartPlateList::update_logo_texture_filename(const std::string &texture_file
|
|||||||
if (!texture_filename.empty() && !check_texture(texture_filename)) {
|
if (!texture_filename.empty() && !check_texture(texture_filename)) {
|
||||||
m_logo_texture_filename = "";
|
m_logo_texture_filename = "";
|
||||||
BOOST_LOG_TRIVIAL(error) << "Unable to load bed texture: " << texture_filename;
|
BOOST_LOG_TRIVIAL(error) << "Unable to load bed texture: " << texture_filename;
|
||||||
} else
|
} else {
|
||||||
m_logo_texture_filename = texture_filename;
|
m_logo_texture_filename = texture_filename;
|
||||||
|
Utils::slash_to_back_slash(m_logo_texture_filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*slice related functions*/
|
/*slice related functions*/
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "FileHelp.hpp"
|
#include "FileHelp.hpp"
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
#include <regex>
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
@@ -20,8 +19,7 @@ bool is_file_too_large(std::string file_path, bool &try_ok)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void slash_to_back_slash(std::string &file_path) {
|
void slash_to_back_slash(std::string &file_path) {
|
||||||
std::regex regex("\\\\");
|
std::replace(file_path.begin(), file_path.end(), '\\', '/');
|
||||||
file_path = std::regex_replace(file_path, regex, "/");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}} // namespace Slic3r::Utils
|
}} // namespace Slic3r::Utils
|
||||||
|
|||||||
Reference in New Issue
Block a user