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 9958 687e118144c7
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
--- a/src/render/opengl/SDL_render_gl.c	Wed Dec 09 21:34:56 2015 -0500
+++ b/src/render/opengl/SDL_render_gl.c	Thu Dec 10 20:25:34 2015 -0400
@@ -393,7 +393,7 @@
     const char *hint;
     GLint value;
     Uint32 window_flags;
-    int profile_mask, major, minor;
+    int profile_mask = 0, major = 0, minor = 0;
     SDL_bool changed_window = SDL_FALSE;
 
     SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);
--- a/src/render/opengles/SDL_render_gles.c	Wed Dec 09 21:34:56 2015 -0500
+++ b/src/render/opengles/SDL_render_gles.c	Thu Dec 10 20:25:34 2015 -0400
@@ -285,7 +285,7 @@
     GLES_RenderData *data;
     GLint value;
     Uint32 window_flags;
-    int profile_mask, major, minor;
+    int profile_mask = 0, major = 0, minor = 0;
     SDL_bool changed_window = SDL_FALSE;
 
     SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);
--- a/src/render/opengles2/SDL_render_gles2.c	Wed Dec 09 21:34:56 2015 -0500
+++ b/src/render/opengles2/SDL_render_gles2.c	Thu Dec 10 20:25:34 2015 -0400
@@ -1956,7 +1956,7 @@
     Uint32 window_flags;
     GLint window_framebuffer;
     GLint value;
-    int profile_mask, major, minor;
+    int profile_mask = 0, major = 0, minor = 0;
     SDL_bool changed_window = SDL_FALSE;
 
     SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);
--- a/src/video/SDL_video.c	Wed Dec 09 21:34:56 2015 -0500
+++ b/src/video/SDL_video.c	Thu Dec 10 20:25:34 2015 -0400
@@ -2913,18 +2913,8 @@
     void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
     GLenum attachment = GL_BACK_LEFT;
     GLenum attachmentattrib = 0;
-
-    glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
-    if (!glGetStringFunc) {
-        return SDL_SetError("Failed getting OpenGL glGetString entry point");
-    }
 #endif
 
-    glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
-    if (!glGetErrorFunc) {
-        return SDL_SetError("Failed getting OpenGL glGetError entry point");
-    }
-
     /* Clear value in any case */
     *value = 0;
 
@@ -3095,6 +3085,11 @@
     }
 
 #if SDL_VIDEO_OPENGL
+    glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
+    if (!glGetStringFunc) {
+        return SDL_SetError("Failed getting OpenGL glGetString entry point");
+    }
+
     if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
         glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
 
@@ -3115,6 +3110,11 @@
         }
     }
 
+    glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
+    if (!glGetErrorFunc) {
+        return SDL_SetError("Failed getting OpenGL glGetError entry point");
+    }
+
     error = glGetErrorFunc();
     if (error != GL_NO_ERROR) {
         if (error == GL_INVALID_ENUM) {