Fixed bug 3173 - SDL_GL_GetAttribute overwrites error code from SDL_GL_GetProcAddress
authorSam Lantinga <slouken@libsdl.org>
Sat, 12 Aug 2017 15:55:54 -0700
changeset 1124900c7bb05a67c
parent 11248 fe8057094a5a
child 11250 c9b15b9a04e3
Fixed bug 3173 - SDL_GL_GetAttribute overwrites error code from SDL_GL_GetProcAddress

Yann Dirson

When SDL_GL_GetProcAddress returns in error, the cause of the error is overwritten
in GL_GL_GetAttribute, reporting to the user "Failed getting OpenGL glGetString entry point", whereas the original "OpenGL library not loaded" never makes it
to the user.

Pushed a fix to:
https://github.com/O-Computers/SDL/commit/f94cb13708ef4d236f8a2a330135b9b3a47db204


Note that the "OpenGL library not loaded" error looks like no root cause either,
and I'm still puzzled by the code path used: I'm forcing opengles2 renderer on
the x11 video driver on a rpi2, as in https://bugzilla.libsdl.org/3169, and although I now know that I must force the use of the RPI video driver instead
of the x11 one, I suspect even more accurate info can be given to user.
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_video.c	Sat Aug 12 15:45:46 2017 -0700
     1.2 +++ b/src/video/SDL_video.c	Sat Aug 12 15:55:54 2017 -0700
     1.3 @@ -3302,7 +3302,7 @@
     1.4  #if SDL_VIDEO_OPENGL
     1.5      glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
     1.6      if (!glGetStringFunc) {
     1.7 -        return SDL_SetError("Failed getting OpenGL glGetString entry point");
     1.8 +        return -1;
     1.9      }
    1.10  
    1.11      if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
    1.12 @@ -3311,7 +3311,7 @@
    1.13          if (glGetFramebufferAttachmentParameterivFunc) {
    1.14              glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, attachmentattrib, (GLint *) value);
    1.15          } else {
    1.16 -            return SDL_SetError("Failed getting OpenGL glGetFramebufferAttachmentParameteriv entry point");
    1.17 +            return -1;
    1.18          }
    1.19      } else
    1.20  #endif
    1.21 @@ -3321,13 +3321,13 @@
    1.22          if (glGetIntegervFunc) {
    1.23              glGetIntegervFunc(attrib, (GLint *) value);
    1.24          } else {
    1.25 -            return SDL_SetError("Failed getting OpenGL glGetIntegerv entry point");
    1.26 +            return -1;
    1.27          }
    1.28      }
    1.29  
    1.30      glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
    1.31      if (!glGetErrorFunc) {
    1.32 -        return SDL_SetError("Failed getting OpenGL glGetError entry point");
    1.33 +        return -1;
    1.34      }
    1.35  
    1.36      error = glGetErrorFunc();