From 7ef1d7b73354cd2cabb33efb57357d30d57ac8ed Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Mon, 28 Dec 2020 09:42:13 -0800 Subject: [PATCH] Fixed crash when MSAA is not available. Fixes #573. --- common/lc_context.cpp | 2 +- common/lc_glextensions.cpp | 60 +++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/common/lc_context.cpp b/common/lc_context.cpp index 674ad274..baa90d46 100644 --- a/common/lc_context.cpp +++ b/common/lc_context.cpp @@ -718,7 +718,7 @@ void lcContext::BindFramebuffer(GLuint FramebufferObject) std::pair lcContext::CreateRenderFramebuffer(int Width, int Height) { #ifdef LC_USE_QOPENGLWIDGET - if (gSupportsFramebufferObject && QSurfaceFormat::defaultFormat().samples() > 1) + if (gSupportsFramebufferObject && gSupportsTexImage2DMultisample && QSurfaceFormat::defaultFormat().samples() > 1) return std::make_pair(CreateFramebuffer(Width, Height, true, true), CreateFramebuffer(Width, Height, false, false)); else return std::make_pair(CreateFramebuffer(Width, Height, true, false), lcFramebuffer()); diff --git a/common/lc_glextensions.cpp b/common/lc_glextensions.cpp index c9e30f11..34c541ed 100644 --- a/common/lc_glextensions.cpp +++ b/common/lc_glextensions.cpp @@ -125,36 +125,6 @@ PFNGLBLENDFUNCSEPARATEPROC lcBlendFuncSeparate; #endif -static bool lcIsGLExtensionSupported(const GLubyte* Extensions, const char* Name) -{ - const GLubyte* Start; - GLubyte* Where; - GLubyte* Terminator; - - Where = (GLubyte*)strchr(Name, ' '); - if (Where || *Name == '\0') - return false; - - if (!Extensions) - return false; - - for (Start = Extensions; ;) - { - Where = (GLubyte*)strstr((const char*)Start, Name); - if (!Where) - break; - - Terminator = Where + strlen(Name); - if (Where == Start || *(Where - 1) == ' ') - if (*Terminator == ' ' || *Terminator == '\0') - return true; - - Start = Terminator; - } - - return false; -} - #if !defined(QT_NO_DEBUG) && defined(GL_ARB_debug_output) static void APIENTRY lcGLDebugCallback(GLenum Source, GLenum Type, GLuint Id, GLenum Severity, GLsizei Length, const GLchar* Message, GLvoid* UserParam) @@ -217,6 +187,36 @@ void lcInitializeGLExtensions(const QOpenGLContext* Context) #else +static bool lcIsGLExtensionSupported(const GLubyte* Extensions, const char* Name) +{ + const GLubyte* Start; + GLubyte* Where; + GLubyte* Terminator; + + Where = (GLubyte*)strchr(Name, ' '); + if (Where || *Name == '\0') + return false; + + if (!Extensions) + return false; + + for (Start = Extensions; ;) + { + Where = (GLubyte*)strstr((const char*)Start, Name); + if (!Where) + break; + + Terminator = Where + strlen(Name); + if (Where == Start || *(Where - 1) == ' ') + if (*Terminator == ' ' || *Terminator == '\0') + return true; + + Start = Terminator; + } + + return false; +} + void lcInitializeGLExtensions(const QGLContext* Context) { const GLubyte* Extensions = glGetString(GL_EXTENSIONS);