From d67d201681f4346f1e05fd95406fa49be5ef106a Mon Sep 17 00:00:00 2001 From: Conn O'Griofa Date: Wed, 20 Dec 2017 07:13:18 +0000 Subject: [PATCH] SDL: really try lower GL profiles & add GLES context support * When compiled with USING_GLES2, attempt to use only valid ES context versions. * Ensure that lower profiles are attempted correctly rather than prematurely returning from the function after the first failure. Needed for Raspberry Pi to successfully launch. --- SDL/SDLMain.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 128e045d4c5e..660663037ffe 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -589,8 +589,12 @@ int main(int argc, char *argv[]) { int minor; }; GLVersionPair attemptVersions[] = { +#ifdef USING_GLES2 + {3, 2}, {3, 1}, {3, 0}, {2, 0}, +#else {4, 6}, {4, 5}, {4, 4}, {4, 3}, {4, 2}, {4, 1}, {4, 0}, {3, 3}, {3, 2}, {3, 1}, {3, 0}, +#endif }; SDL_GLContext glContext = nullptr; @@ -598,17 +602,20 @@ int main(int argc, char *argv[]) { const auto &ver = attemptVersions[i]; // Make sure to request a somewhat modern GL context at least - the // latest supported by MacOS X (really, really sad...) - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, ver.major); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, ver.minor); +#ifdef USING_GLES2 + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + SetGLCoreContext(false); +#else + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SetGLCoreContext(true); +#endif g_Screen = SDL_CreateWindow(app_name_nice.c_str(), x,y, pixel_xres, pixel_yres, mode); if (g_Screen == nullptr) { - NativeShutdown(); fprintf(stderr, "SDL_CreateWindow failed: %s\n", SDL_GetError()); - SDL_Quit(); - return 2; + continue; } glContext = SDL_GL_CreateContext(g_Screen);