SDL_GL_GetAttribute: If a GL context isn't active, only return failure when the specified attribute needs an active GL context to be queried.
authorAlex Szpakowski <slime73@gmail.com>
Thu, 10 Dec 2015 20:25:34 -0400
changeset 9958687e118144c7
parent 9957 0be86b512d34
child 9959 182bfe0e7a60
SDL_GL_GetAttribute: If a GL context isn't active, only return failure when the specified attribute needs an active GL context to be queried.
src/render/opengl/SDL_render_gl.c
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
src/video/SDL_video.c
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Wed Dec 09 21:34:56 2015 -0500
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Thu Dec 10 20:25:34 2015 -0400
     1.3 @@ -393,7 +393,7 @@
     1.4      const char *hint;
     1.5      GLint value;
     1.6      Uint32 window_flags;
     1.7 -    int profile_mask, major, minor;
     1.8 +    int profile_mask = 0, major = 0, minor = 0;
     1.9      SDL_bool changed_window = SDL_FALSE;
    1.10  
    1.11      SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);
     2.1 --- a/src/render/opengles/SDL_render_gles.c	Wed Dec 09 21:34:56 2015 -0500
     2.2 +++ b/src/render/opengles/SDL_render_gles.c	Thu Dec 10 20:25:34 2015 -0400
     2.3 @@ -285,7 +285,7 @@
     2.4      GLES_RenderData *data;
     2.5      GLint value;
     2.6      Uint32 window_flags;
     2.7 -    int profile_mask, major, minor;
     2.8 +    int profile_mask = 0, major = 0, minor = 0;
     2.9      SDL_bool changed_window = SDL_FALSE;
    2.10  
    2.11      SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);
     3.1 --- a/src/render/opengles2/SDL_render_gles2.c	Wed Dec 09 21:34:56 2015 -0500
     3.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Thu Dec 10 20:25:34 2015 -0400
     3.3 @@ -1956,7 +1956,7 @@
     3.4      Uint32 window_flags;
     3.5      GLint window_framebuffer;
     3.6      GLint value;
     3.7 -    int profile_mask, major, minor;
     3.8 +    int profile_mask = 0, major = 0, minor = 0;
     3.9      SDL_bool changed_window = SDL_FALSE;
    3.10  
    3.11      SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);
     4.1 --- a/src/video/SDL_video.c	Wed Dec 09 21:34:56 2015 -0500
     4.2 +++ b/src/video/SDL_video.c	Thu Dec 10 20:25:34 2015 -0400
     4.3 @@ -2913,18 +2913,8 @@
     4.4      void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
     4.5      GLenum attachment = GL_BACK_LEFT;
     4.6      GLenum attachmentattrib = 0;
     4.7 -
     4.8 -    glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
     4.9 -    if (!glGetStringFunc) {
    4.10 -        return SDL_SetError("Failed getting OpenGL glGetString entry point");
    4.11 -    }
    4.12  #endif
    4.13  
    4.14 -    glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
    4.15 -    if (!glGetErrorFunc) {
    4.16 -        return SDL_SetError("Failed getting OpenGL glGetError entry point");
    4.17 -    }
    4.18 -
    4.19      /* Clear value in any case */
    4.20      *value = 0;
    4.21  
    4.22 @@ -3095,6 +3085,11 @@
    4.23      }
    4.24  
    4.25  #if SDL_VIDEO_OPENGL
    4.26 +    glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
    4.27 +    if (!glGetStringFunc) {
    4.28 +        return SDL_SetError("Failed getting OpenGL glGetString entry point");
    4.29 +    }
    4.30 +
    4.31      if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
    4.32          glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
    4.33  
    4.34 @@ -3115,6 +3110,11 @@
    4.35          }
    4.36      }
    4.37  
    4.38 +    glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
    4.39 +    if (!glGetErrorFunc) {
    4.40 +        return SDL_SetError("Failed getting OpenGL glGetError entry point");
    4.41 +    }
    4.42 +
    4.43      error = glGetErrorFunc();
    4.44      if (error != GL_NO_ERROR) {
    4.45          if (error == GL_INVALID_ENUM) {