Tech ENABLE_GL_CORE_PROFILE - Fixed detection of OpenGL extensions and support for newer Mesa drivers

Fixed conflicts during rebase with master
This commit is contained in:
enricoturri1966 2022-03-30 14:46:08 +02:00
parent 2b8ff607bd
commit aaf0861da3
4 changed files with 40 additions and 6 deletions

View File

@ -55,7 +55,7 @@
#define ENABLE_WIPETOWER_OBJECTID_1000_REMOVAL (1 && ENABLE_2_5_0_ALPHA1)
// Enable removal of legacy OpenGL calls
#define ENABLE_LEGACY_OPENGL_REMOVAL (1 && ENABLE_2_5_0_ALPHA1)
// Enable OpenGL core profile context
// Enable OpenGL core profile context (tested against Mesa 20.1.8 on Windows)
#define ENABLE_GL_CORE_PROFILE (1 && ENABLE_LEGACY_OPENGL_REMOVAL)
// Shows an imgui dialog with GLModel statistics data
#define ENABLE_GLMODEL_STATISTICS (0 && ENABLE_LEGACY_OPENGL_REMOVAL)

View File

@ -123,8 +123,14 @@ void GLCanvas3D::LayersEditing::init()
{
glsafe(::glGenTextures(1, (GLuint*)&m_z_texture_id));
glsafe(::glBindTexture(GL_TEXTURE_2D, m_z_texture_id));
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP));
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP));
#if ENABLE_GL_CORE_PROFILE
if (!OpenGLManager::get_gl_info().is_core_profile() || !OpenGLManager::get_gl_info().is_mesa()) {
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP));
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP));
#if ENABLE_GL_CORE_PROFILE
}
#endif // ENABLE_GL_CORE_PROFILE
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST));
glsafe(::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1));

View File

@ -30,6 +30,7 @@ namespace GUI {
std::string gl_get_string_safe(GLenum param, const std::string& default_value)
{
const char* value = (const char*)::glGetString(param);
glcheck();
return std::string((value != nullptr) ? value : default_value);
}
@ -65,10 +66,17 @@ const std::string& OpenGLManager::GLInfo::get_renderer() const
return m_renderer;
}
#if ENABLE_GL_CORE_PROFILE
bool OpenGLManager::GLInfo::is_core_profile() const
{
return !GLEW_ARB_compatibility;
}
bool OpenGLManager::GLInfo::is_mesa() const
{
return boost::icontains(m_version, "mesa");
}
#endif // ENABLE_GL_CORE_PROFILE
int OpenGLManager::GLInfo::get_max_tex_size() const
{
@ -181,7 +189,7 @@ std::string OpenGLManager::GLInfo::to_string(bool for_github) const
out << h2_start << "OpenGL installation" << h2_end << line_end;
out << b_start << "GL version: " << b_end << m_version << line_end;
#if ENABLE_GL_CORE_PROFILE
out << b_start << "Profile: " << b_end << (GLEW_ARB_compatibility ? "Compatibility" : "Core") << line_end;
out << b_start << "Profile: " << b_end << (is_core_profile() ? "Core" : "Compatibility") << line_end;
#endif // ENABLE_GL_CORE_PROFILE
out << b_start << "Vendor: " << b_end << m_vendor << line_end;
out << b_start << "Renderer: " << b_end << m_renderer << line_end;
@ -189,8 +197,25 @@ std::string OpenGLManager::GLInfo::to_string(bool for_github) const
{
std::vector<std::string> extensions_list;
std::string extensions_str = gl_get_string_safe(GL_EXTENSIONS, "");
boost::split(extensions_list, extensions_str, boost::is_any_of(" "), boost::token_compress_on);
#if ENABLE_GL_CORE_PROFILE
std::string extensions_str;
if (is_core_profile()) {
GLint n = 0;
glsafe(::glGetIntegerv(GL_NUM_EXTENSIONS, &n));
for (GLint i = 0; i < n; ++i) {
const char* extension = (const char*)::glGetStringi(GL_EXTENSIONS, i);
glcheck();
if (extension != nullptr)
extensions_list.emplace_back(extension);
}
}
else {
extensions_str = gl_get_string_safe(GL_EXTENSIONS, "");
boost::split(extensions_list, extensions_str, boost::is_any_of(" "), boost::token_compress_on);
}
#else
const std::string extensions_str = gl_get_string_safe(GL_EXTENSIONS, "");
#endif // ENABLE_GL_CORE_PROFILE
if (!extensions_list.empty()) {
if (for_github)

View File

@ -43,7 +43,10 @@ public:
const std::string& get_vendor() const;
const std::string& get_renderer() const;
#if ENABLE_GL_CORE_PROFILE
bool is_core_profile() const;
bool is_mesa() const;
#endif // ENABLE_OPENGL_ES
int get_max_tex_size() const;
float get_max_anisotropy() const;