ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION set as default
This commit is contained in:
parent
96276394d1
commit
301eda7369
@ -49,7 +49,4 @@
|
|||||||
// Enable saving textures on GPU in compressed format
|
// Enable saving textures on GPU in compressed format
|
||||||
#define ENABLE_COMPRESSED_TEXTURES 1
|
#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_
|
#endif // _technologies_h_
|
||||||
|
@ -546,7 +546,6 @@ void Bed3D::render_prusa(const std::string &key, bool bottom) const
|
|||||||
|
|
||||||
std::string model_path = resources_dir() + "/models/" + key;
|
std::string model_path = resources_dir() + "/models/" + key;
|
||||||
|
|
||||||
#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
#if !ENABLE_COMPRESSED_TEXTURES
|
#if !ENABLE_COMPRESSED_TEXTURES
|
||||||
// use anisotropic filter if graphic card allows
|
// use anisotropic filter if graphic card allows
|
||||||
GLfloat max_anisotropy = GLCanvas3DManager::get_gl_info().get_max_anisotropy();
|
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
|
// use higher resolution images if graphic card and opengl version allow
|
||||||
GLint max_tex_size = GLCanvas3DManager::get_gl_info().get_max_tex_size();
|
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";
|
std::string filename = tex_path + ".svg";
|
||||||
|
|
||||||
|
@ -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)
|
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);
|
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)
|
bool _3DScene::add_canvas(wxGLCanvas* canvas, GUI::Bed3D& bed, GUI::Camera& camera, GUI::GLToolbar& view_toolbar)
|
||||||
|
@ -1756,11 +1756,9 @@ void GLCanvas3D::render()
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
imgui.text(GLCanvas3DManager::are_compressed_textures_supported() ? "supported" : "not supported");
|
imgui.text(GLCanvas3DManager::are_compressed_textures_supported() ? "supported" : "not supported");
|
||||||
#endif // ENABLE_COMPRESSED_TEXTURES
|
#endif // ENABLE_COMPRESSED_TEXTURES
|
||||||
#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
imgui.text("Max texture size: ");
|
imgui.text("Max texture size: ");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
imgui.text(std::to_string(GLCanvas3DManager::get_gl_info().get_max_tex_size()));
|
imgui.text(std::to_string(GLCanvas3DManager::get_gl_info().get_max_tex_size()));
|
||||||
#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
imgui.end();
|
imgui.end();
|
||||||
#endif // ENABLE_RENDER_STATISTICS
|
#endif // ENABLE_RENDER_STATISTICS
|
||||||
|
|
||||||
|
@ -15,17 +15,14 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "../Utils/MacDarkMode.hpp"
|
#include "../Utils/MacDarkMode.hpp"
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
GLCanvas3DManager::GLInfo::GLInfo()
|
GLCanvas3DManager::GLInfo::GLInfo()
|
||||||
#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
: m_detected(false)
|
: m_detected(false)
|
||||||
, m_version("")
|
, m_version("")
|
||||||
, m_glsl_version("")
|
, m_glsl_version("")
|
||||||
@ -33,16 +30,9 @@ GLCanvas3DManager::GLInfo::GLInfo()
|
|||||||
, m_renderer("")
|
, m_renderer("")
|
||||||
, m_max_tex_size(0)
|
, m_max_tex_size(0)
|
||||||
, m_max_anisotropy(0.0f)
|
, 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
|
const std::string& GLCanvas3DManager::GLInfo::get_version() const
|
||||||
{
|
{
|
||||||
if (!m_detected)
|
if (!m_detected)
|
||||||
@ -123,28 +113,7 @@ void GLCanvas3DManager::GLInfo::detect() const
|
|||||||
|
|
||||||
m_detected = true;
|
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
|
bool GLCanvas3DManager::GLInfo::is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const
|
||||||
{
|
{
|
||||||
if (!m_detected)
|
if (!m_detected)
|
||||||
@ -175,42 +144,11 @@ bool GLCanvas3DManager::GLInfo::is_version_greater_or_equal_to(unsigned int majo
|
|||||||
else
|
else
|
||||||
return gl_minor >= minor;
|
return gl_minor >= minor;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
bool GLCanvas3DManager::GLInfo::is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const
|
|
||||||
{
|
|
||||||
std::vector<std::string> tokens;
|
|
||||||
boost::split(tokens, version, boost::is_any_of(" "), boost::token_compress_on);
|
|
||||||
|
|
||||||
if (tokens.empty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
std::vector<std::string> 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
|
std::string GLCanvas3DManager::GLInfo::to_string(bool format_as_html, bool extensions) const
|
||||||
{
|
{
|
||||||
#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
if (!m_detected)
|
if (!m_detected)
|
||||||
detect();
|
detect();
|
||||||
#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
|
|
||||||
std::stringstream out;
|
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 ? "<br>" : "\n";
|
std::string line_end = format_as_html ? "<br>" : "\n";
|
||||||
|
|
||||||
out << h2_start << "OpenGL installation" << h2_end << line_end;
|
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 << "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 << "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 << "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;
|
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)
|
if (extensions)
|
||||||
{
|
{
|
||||||
@ -258,9 +189,7 @@ GLCanvas3DManager::EMultisampleState GLCanvas3DManager::s_multisample = GLCanvas
|
|||||||
#if ENABLE_COMPRESSED_TEXTURES
|
#if ENABLE_COMPRESSED_TEXTURES
|
||||||
bool GLCanvas3DManager::s_compressed_textures_supported = false;
|
bool GLCanvas3DManager::s_compressed_textures_supported = false;
|
||||||
#endif // ENABLE_COMPRESSED_TEXTURES
|
#endif // ENABLE_COMPRESSED_TEXTURES
|
||||||
#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
GLCanvas3DManager::GLInfo GLCanvas3DManager::s_gl_info;
|
GLCanvas3DManager::GLInfo GLCanvas3DManager::s_gl_info;
|
||||||
#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
|
|
||||||
GLCanvas3DManager::GLCanvas3DManager()
|
GLCanvas3DManager::GLCanvas3DManager()
|
||||||
: m_context(nullptr)
|
: m_context(nullptr)
|
||||||
@ -340,16 +269,9 @@ void GLCanvas3DManager::init_gl()
|
|||||||
if (!m_gl_initialized)
|
if (!m_gl_initialized)
|
||||||
{
|
{
|
||||||
glewInit();
|
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();
|
const AppConfig* config = GUI::get_app_config();
|
||||||
m_use_legacy_opengl = (config == nullptr) || (config->get("use_legacy_opengl") == "1");
|
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);
|
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;
|
m_gl_initialized = true;
|
||||||
#if ENABLE_COMPRESSED_TEXTURES
|
#if ENABLE_COMPRESSED_TEXTURES
|
||||||
if (GLEW_EXT_texture_compression_s3tc)
|
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)
|
bool GLCanvas3DManager::init(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
CanvasesMap::const_iterator it = do_get_canvas(canvas);
|
CanvasesMap::const_iterator it = do_get_canvas(canvas);
|
||||||
|
@ -29,7 +29,6 @@ struct Camera;
|
|||||||
|
|
||||||
class GLCanvas3DManager
|
class GLCanvas3DManager
|
||||||
{
|
{
|
||||||
#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
public:
|
public:
|
||||||
class GLInfo
|
class GLInfo
|
||||||
{
|
{
|
||||||
@ -61,26 +60,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
void detect() const;
|
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:
|
private:
|
||||||
#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
enum EMultisampleState : unsigned char
|
enum EMultisampleState : unsigned char
|
||||||
{
|
{
|
||||||
MS_Unknown,
|
MS_Unknown,
|
||||||
@ -92,11 +73,7 @@ private:
|
|||||||
|
|
||||||
CanvasesMap m_canvases;
|
CanvasesMap m_canvases;
|
||||||
wxGLContext* m_context;
|
wxGLContext* m_context;
|
||||||
#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
static GLInfo s_gl_info;
|
static GLInfo s_gl_info;
|
||||||
#else
|
|
||||||
GLInfo m_gl_info;
|
|
||||||
#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
bool m_gl_initialized;
|
bool m_gl_initialized;
|
||||||
bool m_use_legacy_opengl;
|
bool m_use_legacy_opengl;
|
||||||
bool m_use_VBOs;
|
bool m_use_VBOs;
|
||||||
@ -116,9 +93,6 @@ public:
|
|||||||
unsigned int count() const;
|
unsigned int count() const;
|
||||||
|
|
||||||
void init_gl();
|
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);
|
bool init(wxGLCanvas* canvas);
|
||||||
|
|
||||||
@ -131,9 +105,7 @@ public:
|
|||||||
|
|
||||||
static wxGLCanvas* create_wxglcanvas(wxWindow *parent);
|
static wxGLCanvas* create_wxglcanvas(wxWindow *parent);
|
||||||
|
|
||||||
#if ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
static const GLInfo& get_gl_info() { return s_gl_info; }
|
static const GLInfo& get_gl_info() { return s_gl_info; }
|
||||||
#endif // ENABLE_TEXTURES_MAXSIZE_DEPENDENT_ON_OPENGL_VERSION
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CanvasesMap::iterator do_get_canvas(wxGLCanvas* canvas);
|
CanvasesMap::iterator do_get_canvas(wxGLCanvas* canvas);
|
||||||
|
Loading…
Reference in New Issue
Block a user