Skip to content

Commit

Permalink
Check if deprecated function works
Browse files Browse the repository at this point in the history
Some systems when using an OpenGL 3.0 or higher context, do not support pre-3.0 functionality, even though a
compatibility profile is selected (for OpenGL >= 3.2), the ARB_compatibility extension is supported (for OpenGL 3.1),
or OpenGL 3.0 is used which deprecated this functionality but should not remove it.

Do a quick test to see if a deprecated function (glGetString(GL_EXTENSIONS)) can be used, and if that does not
work, choose a lower version context.
  • Loading branch information
gvissers committed Feb 10, 2022
1 parent 503a4bf commit 94064e9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion gl_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,19 @@ void init_video(void)
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, versions_to_try[i][2]);
el_gl_context = SDL_GL_CreateContext(el_gl_window);
if (el_gl_context)
break;
{
// OpenGL deprecated a lot of features we use in OpenGL 3.0, and removed them in
// 3.1. OpenGL. OpenGL 3.2 introduced compatibility profiles, and 3.1 has the
// ARB_compativility extension, but some systems fail with an OpenGL context >= 3.0
// even when they report compatibility, or when the context is OpenGL 3.0 which should
// still support the old functionality, Therefore, try a deprecated function here,
// and if it fails, downgrade to a lower version context.
const GLubyte* extensions_str = glGetString(GL_EXTENSIONS);
DO_CHECK_GL_ERRORS();
if (extensions_str)
// That seemd to work, hopefully we're good
break;
}
}
if (el_gl_context == NULL)
{
Expand Down

0 comments on commit 94064e9

Please sign in to comment.