OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::OpenGLManager::GLInfo Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/OpenGLManager.hpp>

Collaboration diagram for Slic3r::GUI::OpenGLManager::GLInfo:

Public Member Functions

 GLInfo ()=default
const std::string & get_version () const
const std::string & get_glsl_version () const
const std::string & get_vendor () const
const std::string & get_renderer () const
bool is_detected () const
bool is_core_profile () const
bool is_mesa () const
int get_max_tex_size () const
float get_max_anisotropy () const
bool is_version_greater_or_equal_to (unsigned int major, unsigned int minor) const
bool is_glsl_version_greater_or_equal_to (unsigned int major, unsigned int minor) const
std::string to_string (bool for_github) const

Private Member Functions

void detect () const

Private Attributes

bool m_detected { false }
bool m_core_profile { false }
int m_max_tex_size { 0 }
float m_max_anisotropy { 0.0f }
std::string m_version
std::string m_glsl_version
std::string m_vendor
std::string m_renderer

Detailed Description

Constructor & Destructor Documentation

◆ GLInfo()

Slic3r::GUI::OpenGLManager::GLInfo::GLInfo ( )
default

Member Function Documentation

◆ detect()

void Slic3r::GUI::OpenGLManager::GLInfo::detect ( ) const
private
119{
120 *const_cast<std::string*>(&m_version) = gl_get_string_safe(GL_VERSION, "N/A");
121 *const_cast<std::string*>(&m_glsl_version) = gl_get_string_safe(GL_SHADING_LANGUAGE_VERSION, "N/A");
122 *const_cast<std::string*>(&m_vendor) = gl_get_string_safe(GL_VENDOR, "N/A");
123 *const_cast<std::string*>(&m_renderer) = gl_get_string_safe(GL_RENDERER, "N/A");
124
125 BOOST_LOG_TRIVIAL(info) << boost::format("got opengl version %1%, glsl version %2%, vendor %3% , graphics card model %4%") % m_version % m_glsl_version % m_vendor % m_renderer << std::endl;
126
127 int* max_tex_size = const_cast<int*>(&m_max_tex_size);
129
130 *max_tex_size /= 2;
131
132 if (Slic3r::total_physical_memory() / (1024 * 1024 * 1024) < 6)
133 *max_tex_size /= 2;
134
136 float* max_anisotropy = const_cast<float*>(&m_max_anisotropy);
138 }
139
141 *const_cast<bool*>(&m_core_profile) = true;
142
143 *const_cast<bool*>(&m_detected) = true;
144}
#define glsafe(cmd)
Definition OpenGLUtils.hpp:25
int m_max_tex_size
Definition OpenGLManager.hpp:31
float m_max_anisotropy
Definition OpenGLManager.hpp:32
std::string m_renderer
Definition OpenGLManager.hpp:40
bool m_core_profile
Definition OpenGLManager.hpp:30
std::string m_version
Definition OpenGLManager.hpp:37
std::string m_vendor
Definition OpenGLManager.hpp:39
bool m_detected
Definition OpenGLManager.hpp:29
std::string m_glsl_version
Definition OpenGLManager.hpp:38
#define GL_MAX_TEXTURE_SIZE
Definition gl.h:1146
#define glGetFloatv
Definition gl.h:3853
#define GL_VERSION
Definition gl.h:1987
#define glGetIntegerv
Definition gl.h:3873
GLAD_API_CALL int GLAD_GL_EXT_texture_filter_anisotropic
Definition gl.h:2169
#define GL_SHADING_LANGUAGE_VERSION
Definition gl.h:1582
#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
Definition gl.h:1145
#define GL_RENDERER
Definition gl.h:1451
#define GL_VENDOR
Definition gl.h:1986
GLAD_API_CALL int GLAD_GL_ARB_compatibility
Definition gl.h:2157
std::string gl_get_string_safe(GLenum param, const std::string &default_value)
Definition OpenGLManager.cpp:52
size_t total_physical_memory()
Definition utils.cpp:1819

References Slic3r::GUI::gl_get_string_safe(), GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, GL_MAX_TEXTURE_SIZE, GL_RENDERER, GL_SHADING_LANGUAGE_VERSION, GL_VENDOR, GL_VERSION, GLAD_GL_ARB_compatibility, GLAD_GL_EXT_texture_filter_anisotropic, glGetFloatv, glGetIntegerv, glsafe, m_core_profile, m_detected, m_glsl_version, m_max_anisotropy, m_max_tex_size, m_renderer, m_vendor, m_version, and Slic3r::total_physical_memory().

Referenced by get_glsl_version(), get_max_anisotropy(), get_max_tex_size(), get_renderer(), get_vendor(), get_version(), is_glsl_version_greater_or_equal_to(), is_version_greater_or_equal_to(), and to_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_glsl_version()

const std::string & Slic3r::GUI::OpenGLManager::GLInfo::get_glsl_version ( ) const
67{
68 if (!m_detected)
69 detect();
70
71 return m_glsl_version;
72}
void detect() const
Definition OpenGLManager.cpp:118

References detect(), m_detected, and m_glsl_version.

Referenced by Slic3r::anonymous_namespace{PluginHostApp.cpp}::gl_info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_max_anisotropy()

float Slic3r::GUI::OpenGLManager::GLInfo::get_max_anisotropy ( ) const
111{
112 if (!m_detected)
113 detect();
114
115 return m_max_anisotropy;
116}

References detect(), m_detected, and m_max_anisotropy.

Referenced by Slic3r::GUI::GLTexture::load_from_png(), Slic3r::GUI::GLTexture::load_from_raw_data(), and Slic3r::GUI::GLTexture::load_from_svg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_max_tex_size()

int Slic3r::GUI::OpenGLManager::GLInfo::get_max_tex_size ( ) const
96{
97 if (!m_detected)
98 detect();
99
100 // clamp to avoid the texture generation become too slow and use too much GPU memory
101#ifdef __APPLE__
102 // and use smaller texture for non retina systems
103 return (Slic3r::GUI::mac_max_scaling_factor() > 1.0) ? std::min(m_max_tex_size, 8192) : std::min(m_max_tex_size / 2, 4096);
104#else
105 // and use smaller texture for older OpenGL versions
106 return is_version_greater_or_equal_to(3, 0) ? std::min(m_max_tex_size, 8192) : std::min(m_max_tex_size / 2, 4096);
107#endif // __APPLE__
108}
bool is_version_greater_or_equal_to(unsigned int major, unsigned int minor) const
Definition OpenGLManager.cpp:177
double mac_max_scaling_factor()
Definition MacDarkMode.mm:35

References detect(), is_version_greater_or_equal_to(), m_detected, m_max_tex_size, and Slic3r::GUI::mac_max_scaling_factor().

Referenced by Slic3r::GUI::PartPlateList::generate_icon_textures().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_renderer()

const std::string & Slic3r::GUI::OpenGLManager::GLInfo::get_renderer ( ) const
83{
84 if (!m_detected)
85 detect();
86
87 return m_renderer;
88}

References detect(), m_detected, and m_renderer.

Referenced by Slic3r::anonymous_namespace{PluginHostApp.cpp}::gl_info(), Slic3r::GUI::anonymous_namespace{SceneBenchmark.cpp}::SceneBenchmarkDialog::report(), and Slic3r::GUI::DesignCanvas::request_repaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_vendor()

const std::string & Slic3r::GUI::OpenGLManager::GLInfo::get_vendor ( ) const
75{
76 if (!m_detected)
77 detect();
78
79 return m_vendor;
80}

References detect(), m_detected, and m_vendor.

Referenced by Slic3r::anonymous_namespace{PluginHostApp.cpp}::gl_info().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_version()

const std::string & Slic3r::GUI::OpenGLManager::GLInfo::get_version ( ) const
59{
60 if (!m_detected)
61 detect();
62
63 return m_version;
64}

References detect(), m_detected, and m_version.

Referenced by Slic3r::anonymous_namespace{PluginHostApp.cpp}::gl_info(), and Slic3r::GUI::anonymous_namespace{SceneBenchmark.cpp}::SceneBenchmarkDialog::report().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_core_profile()

◆ is_detected()

bool Slic3r::GUI::OpenGLManager::GLInfo::is_detected ( ) const
inline
52{ return m_detected; }

References m_detected.

Referenced by Slic3r::anonymous_namespace{PluginHostApp.cpp}::gl_info().

Here is the caller graph for this function:

◆ is_glsl_version_greater_or_equal_to()

bool Slic3r::GUI::OpenGLManager::GLInfo::is_glsl_version_greater_or_equal_to ( unsigned int major,
unsigned int minor ) const
186{
187 if (!m_detected)
188 detect();
189
190 return version_greater_or_equal_to(m_glsl_version, major, minor);
191}
static bool version_greater_or_equal_to(const std::string &version, unsigned int major, unsigned int minor)
Definition OpenGLManager.cpp:146

References detect(), m_detected, m_glsl_version, and Slic3r::GUI::version_greater_or_equal_to().

Here is the call graph for this function:

◆ is_mesa()

bool Slic3r::GUI::OpenGLManager::GLInfo::is_mesa ( ) const
91{
92 return boost::icontains(m_version, "mesa");
93}

References m_version.

◆ is_version_greater_or_equal_to()

bool Slic3r::GUI::OpenGLManager::GLInfo::is_version_greater_or_equal_to ( unsigned int major,
unsigned int minor ) const
178{
179 if (!m_detected)
180 detect();
181
182 return version_greater_or_equal_to(m_version, major, minor);
183}

References detect(), m_detected, m_version, and Slic3r::GUI::version_greater_or_equal_to().

Referenced by get_max_tex_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_string()

std::string Slic3r::GUI::OpenGLManager::GLInfo::to_string ( bool for_github) const
196{
197 if (!m_detected)
198 detect();
199
200 std::stringstream out;
201
202 const bool format_as_html = ! for_github;
203 std::string h2_start = format_as_html ? "<b>" : "";
204 std::string h2_end = format_as_html ? "</b>" : "";
205 std::string b_start = format_as_html ? "<b>" : "";
206 std::string b_end = format_as_html ? "</b>" : "";
207 std::string line_end = format_as_html ? "<br>" : "\n";
208
209 out << h2_start << "OpenGL installation" << h2_end << line_end;
210 out << b_start << "GL version: " << b_end << m_version << line_end;
211#if !SLIC3R_OPENGL_ES
212 out << b_start << "Profile: " << b_end << (is_core_profile() ? "Core" : "Compatibility") << line_end;
213#endif // !SLIC3R_OPENGL_ES
214 out << b_start << "Vendor: " << b_end << m_vendor << line_end;
215 out << b_start << "Renderer: " << b_end << m_renderer << line_end;
216 out << b_start << "GLSL version: " << b_end << m_glsl_version << line_end;
217
218 {
219 std::vector<std::string> extensions_list;
220 std::string extensions_str = gl_get_string_safe(GL_EXTENSIONS, "");
221 boost::split(extensions_list, extensions_str, boost::is_any_of(" "), boost::token_compress_on);
222
223 if (!extensions_list.empty()) {
224 if (for_github)
225 out << "<details>\n<summary>Installed extensions:</summary>\n";
226 else
227 out << h2_start << "Installed extensions:" << h2_end << line_end;
228
229 std::sort(extensions_list.begin(), extensions_list.end());
230 for (const std::string& ext : extensions_list)
231 if (! ext.empty())
232 out << ext << line_end;
233
234 if (for_github)
235 out << "</details>\n";
236 }
237 }
238
239 return out.str();
240}
bool is_core_profile() const
Definition OpenGLManager.hpp:53
#define GL_EXTENSIONS
Definition gl.h:645

References detect(), GL_EXTENSIONS, Slic3r::GUI::gl_get_string_safe(), is_core_profile(), m_detected, m_glsl_version, m_renderer, m_vendor, and m_version.

Here is the call graph for this function:

Member Data Documentation

◆ m_core_profile

bool Slic3r::GUI::OpenGLManager::GLInfo::m_core_profile { false }
private
30{ false };

Referenced by detect(), and is_core_profile().

◆ m_detected

◆ m_glsl_version

std::string Slic3r::GUI::OpenGLManager::GLInfo::m_glsl_version
private

◆ m_max_anisotropy

float Slic3r::GUI::OpenGLManager::GLInfo::m_max_anisotropy { 0.0f }
private
32{ 0.0f };

Referenced by detect(), and get_max_anisotropy().

◆ m_max_tex_size

int Slic3r::GUI::OpenGLManager::GLInfo::m_max_tex_size { 0 }
private
31{ 0 };

Referenced by detect(), and get_max_tex_size().

◆ m_renderer

std::string Slic3r::GUI::OpenGLManager::GLInfo::m_renderer
private

Referenced by detect(), get_renderer(), and to_string().

◆ m_vendor

std::string Slic3r::GUI::OpenGLManager::GLInfo::m_vendor
private

Referenced by detect(), get_vendor(), and to_string().

◆ m_version

std::string Slic3r::GUI::OpenGLManager::GLInfo::m_version
private

The documentation for this class was generated from the following files: