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:
parent
d9f8ea74e9
commit
199885baa8
1 changed files with 17 additions and 0 deletions
|
|
@ -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?
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue