diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index d7e5aed76..657dab95f 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -49,7 +49,4 @@ // Enable saving textures on GPU in compressed format #define ENABLE_COMPRESSED_TEXTURES 1 -// Enable texture max size to be dependent on detected OpenGL version -#define ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION 1 - #endif // _technologies_h_ diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp index 04ab4e2da..d63e054c5 100644 --- a/src/slic3r/GUI/3DBed.cpp +++ b/src/slic3r/GUI/3DBed.cpp @@ -546,7 +546,6 @@ void Bed3D::render_prusa(const std::string &key, bool bottom) const std::string model_path = resources_dir() + "/models/" + key; -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION #if !ENABLE_COMPRESSED_TEXTURES // use anisotropic filter if graphic card allows GLfloat max_anisotropy = GLCanvas3DManager::get_gl_info().get_max_anisotropy(); @@ -554,21 +553,6 @@ void Bed3D::render_prusa(const std::string &key, bool bottom) const // use higher resolution images if graphic card and opengl version allow GLint max_tex_size = GLCanvas3DManager::get_gl_info().get_max_tex_size(); -#else -#if !ENABLE_COMPRESSED_TEXTURES - // use anisotropic filter if graphic card allows - GLfloat max_anisotropy = 0.0f; - if (glewIsSupported("GL_EXT_texture_filter_anisotropic")) - glsafe(::glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy)); -#endif // !ENABLE_COMPRESSED_TEXTURES - - // use higher resolution images if graphic card allows - GLint max_tex_size; - glsafe(::glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_tex_size)); - - // clamp or the texture generation becomes too slow - max_tex_size = std::min(max_tex_size, 8192); -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION std::string filename = tex_path + ".svg"; diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 2e30f00ca..f9a79f2d8 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -2015,11 +2015,7 @@ bool GLBed::on_init_from_file(const std::string& filename, bool useVBOs) std::string _3DScene::get_gl_info(bool format_as_html, bool extensions) { -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION return Slic3r::GUI::GLCanvas3DManager::get_gl_info().to_string(format_as_html, extensions); -#else - return s_canvas_mgr.get_gl_info(format_as_html, extensions); -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION } bool _3DScene::add_canvas(wxGLCanvas* canvas, GUI::Bed3D& bed, GUI::Camera& camera, GUI::GLToolbar& view_toolbar) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index a71c03096..973fd1dd9 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1756,11 +1756,9 @@ void GLCanvas3D::render() ImGui::SameLine(); imgui.text(GLCanvas3DManager::are_compressed_textures_supported() ? "supported" : "not supported"); #endif // ENABLE_COMPRESSED_TEXTURES -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION imgui.text("Max texture size: "); ImGui::SameLine(); imgui.text(std::to_string(GLCanvas3DManager::get_gl_info().get_max_tex_size())); -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION imgui.end(); #endif // ENABLE_RENDER_STATISTICS diff --git a/src/slic3r/GUI/GLCanvas3DManager.cpp b/src/slic3r/GUI/GLCanvas3DManager.cpp index d213990ba..a123fcfa7 100644 --- a/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -15,17 +15,14 @@ #include #include -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION #ifdef __APPLE__ #include "../Utils/MacDarkMode.hpp" #endif // __APPLE__ -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION namespace Slic3r { namespace GUI { GLCanvas3DManager::GLInfo::GLInfo() -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION : m_detected(false) , m_version("") , m_glsl_version("") @@ -33,16 +30,9 @@ GLCanvas3DManager::GLInfo::GLInfo() , m_renderer("") , m_max_tex_size(0) , m_max_anisotropy(0.0f) -#else - : version("") - , glsl_version("") - , vendor("") - , renderer("") -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION { } -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION const std::string& GLCanvas3DManager::GLInfo::get_version() const { if (!m_detected) @@ -123,28 +113,7 @@ void GLCanvas3DManager::GLInfo::detect() const m_detected = true; } -#else -void GLCanvas3DManager::GLInfo::detect() -{ - const char* data = (const char*)::glGetString(GL_VERSION); - if (data != nullptr) - version = data; - data = (const char*)::glGetString(GL_SHADING_LANGUAGE_VERSION); - if (data != nullptr) - glsl_version = data; - - data = (const char*)::glGetString(GL_VENDOR); - if (data != nullptr) - vendor = data; - - data = (const char*)::glGetString(GL_RENDERER); - if (data != nullptr) - renderer = data; -} -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION - -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION bool GLCanvas3DManager::GLInfo::is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const { if (!m_detected) @@ -175,42 +144,11 @@ bool GLCanvas3DManager::GLInfo::is_version_greater_or_equal_to(unsigned int majo else return gl_minor >= minor; } -#else -bool GLCanvas3DManager::GLInfo::is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const -{ - std::vector tokens; - boost::split(tokens, version, boost::is_any_of(" "), boost::token_compress_on); - - if (tokens.empty()) - return false; - - std::vector numbers; - boost::split(numbers, tokens[0], boost::is_any_of("."), boost::token_compress_on); - - unsigned int gl_major = 0; - unsigned int gl_minor = 0; - - if (numbers.size() > 0) - gl_major = ::atoi(numbers[0].c_str()); - - if (numbers.size() > 1) - gl_minor = ::atoi(numbers[1].c_str()); - - if (gl_major < major) - return false; - else if (gl_major > major) - return true; - else - return gl_minor >= minor; -} -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool extensions) const { -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION if (!m_detected) detect(); -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION std::stringstream out; @@ -221,17 +159,10 @@ std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool exten std::string line_end = format_as_html ? "
" : "\n"; out << h2_start << "OpenGL installation" << h2_end << line_end; -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION out << b_start << "GL version: " << b_end << (m_version.empty() ? "N/A" : m_version) << line_end; out << b_start << "Vendor: " << b_end << (m_vendor.empty() ? "N/A" : m_vendor) << line_end; out << b_start << "Renderer: " << b_end << (m_renderer.empty() ? "N/A" : m_renderer) << line_end; out << b_start << "GLSL version: " << b_end << (m_glsl_version.empty() ? "N/A" : m_glsl_version) << line_end; -#else - out << b_start << "GL version: " << b_end << (version.empty() ? "N/A" : version) << line_end; - out << b_start << "Vendor: " << b_end << (vendor.empty() ? "N/A" : vendor) << line_end; - out << b_start << "Renderer: " << b_end << (renderer.empty() ? "N/A" : renderer) << line_end; - out << b_start << "GLSL version: " << b_end << (glsl_version.empty() ? "N/A" : glsl_version) << line_end; -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION if (extensions) { @@ -258,9 +189,7 @@ GLCanvas3DManager::EMultisampleState GLCanvas3DManager::s_multisample = GLCanvas #if ENABLE_COMPRESSED_TEXTURES bool GLCanvas3DManager::s_compressed_textures_supported = false; #endif // ENABLE_COMPRESSED_TEXTURES -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION GLCanvas3DManager::GLInfo GLCanvas3DManager::s_gl_info; -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION GLCanvas3DManager::GLCanvas3DManager() : m_context(nullptr) @@ -340,16 +269,9 @@ void GLCanvas3DManager::init_gl() if (!m_gl_initialized) { glewInit(); -#if !ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION - m_gl_info.detect(); -#endif // !ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION const AppConfig* config = GUI::get_app_config(); m_use_legacy_opengl = (config == nullptr) || (config->get("use_legacy_opengl") == "1"); -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION m_use_VBOs = !m_use_legacy_opengl && s_gl_info.is_version_greater_or_equal_to(2, 0); -#else - m_use_VBOs = !m_use_legacy_opengl && m_gl_info.is_version_greater_or_equal_to(2, 0); -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION m_gl_initialized = true; #if ENABLE_COMPRESSED_TEXTURES if (GLEW_EXT_texture_compression_s3tc) @@ -360,13 +282,6 @@ void GLCanvas3DManager::init_gl() } } -#if !ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION -std::string GLCanvas3DManager::get_gl_info(bool format_as_html, bool extensions) const -{ - return m_gl_info.to_string(format_as_html, extensions); -} -#endif // !ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION - bool GLCanvas3DManager::init(wxGLCanvas* canvas) { CanvasesMap::const_iterator it = do_get_canvas(canvas); diff --git a/src/slic3r/GUI/GLCanvas3DManager.hpp b/src/slic3r/GUI/GLCanvas3DManager.hpp index 3ad30411c..e6e12ca5d 100644 --- a/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -29,7 +29,6 @@ struct Camera; class GLCanvas3DManager { -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION public: class GLInfo { @@ -61,26 +60,8 @@ public: private: void detect() const; }; -#else - struct GLInfo - { - std::string version; - std::string glsl_version; - std::string vendor; - std::string renderer; - GLInfo(); - - void detect(); - bool is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const; - - std::string to_string(bool format_as_html, bool extensions) const; - }; -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION - -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION private: -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION enum EMultisampleState : unsigned char { MS_Unknown, @@ -92,11 +73,7 @@ private: CanvasesMap m_canvases; wxGLContext* m_context; -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION static GLInfo s_gl_info; -#else - GLInfo m_gl_info; -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION bool m_gl_initialized; bool m_use_legacy_opengl; bool m_use_VBOs; @@ -116,9 +93,6 @@ public: unsigned int count() const; void init_gl(); -#if !ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION - std::string get_gl_info(bool format_as_html, bool extensions) const; -#endif // !ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION bool init(wxGLCanvas* canvas); @@ -131,9 +105,7 @@ public: static wxGLCanvas* create_wxglcanvas(wxWindow *parent); -#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION static const GLInfo& get_gl_info() { return s_gl_info; } -#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION private: CanvasesMap::iterator do_get_canvas(wxGLCanvas* canvas);