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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c
index f5ac96d..6b82566 100644
--- a/src/render/opengl/SDL_render_gl.c
+++ b/src/render/opengl/SDL_render_gl.c
@@ -393,7 +393,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
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);
diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c
index 21c22bf..18329d7 100644
--- a/src/render/opengles/SDL_render_gles.c
+++ b/src/render/opengles/SDL_render_gles.c
@@ -285,7 +285,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
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);
diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index 7254cb7..b911b66 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -1956,7 +1956,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
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);
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 753eac9..68a5ab4 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -2913,18 +2913,8 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
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 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
}
#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 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
}
}
+ 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) {