1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

OpenGL: Avoid deprecated function when querying available extensions

In OpenGL 3 and up, GL_EXTENSIONS is deprecated as an argument of
glGetString and glGetStringi should be used instead.
This commit is contained in:
reuk 2022-02-09 18:47:58 +00:00
parent d9f8ea74e9
commit 199885baa8
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -133,6 +133,23 @@ bool OpenGLHelpers::isExtensionSupported (const char* const extensionName)
jassert (extensionName != nullptr); // you must supply a genuine string for this.
jassert (isContextActive()); // An OpenGL context will need to be active before calling this.
if (getOpenGLVersion().major >= 3)
{
using GetStringi = const GLubyte* (*) (GLenum, GLuint);
if (auto* thisGlGetStringi = reinterpret_cast<GetStringi> (getExtensionFunction ("glGetStringi")))
{
GLint n = 0;
glGetIntegerv (GL_NUM_EXTENSIONS, &n);
for (auto i = (decltype (n)) 0; i < n; ++i)
if (StringRef (extensionName) == StringRef ((const char*) thisGlGetStringi (GL_EXTENSIONS, (GLuint) i)))
return true;
return false;
}
}
const char* extensions = (const char*) glGetString (GL_EXTENSIONS);
jassert (extensions != nullptr); // Perhaps you didn't activate an OpenGL context before calling this?