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.

This commit is contained in:
Alex Szpakowski 2015-12-10 20:25:34 -04:00
parent f2f435ee45
commit 0c463d770b
4 changed files with 13 additions and 13 deletions

View File

@ -393,7 +393,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
const char *hint; const char *hint;
GLint value; GLint value;
Uint32 window_flags; Uint32 window_flags;
int profile_mask, major, minor; int profile_mask = 0, major = 0, minor = 0;
SDL_bool changed_window = SDL_FALSE; SDL_bool changed_window = SDL_FALSE;
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask); SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);

View File

@ -285,7 +285,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
GLES_RenderData *data; GLES_RenderData *data;
GLint value; GLint value;
Uint32 window_flags; Uint32 window_flags;
int profile_mask, major, minor; int profile_mask = 0, major = 0, minor = 0;
SDL_bool changed_window = SDL_FALSE; SDL_bool changed_window = SDL_FALSE;
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask); SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);

View File

@ -1956,7 +1956,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
Uint32 window_flags; Uint32 window_flags;
GLint window_framebuffer; GLint window_framebuffer;
GLint value; GLint value;
int profile_mask, major, minor; int profile_mask = 0, major = 0, minor = 0;
SDL_bool changed_window = SDL_FALSE; SDL_bool changed_window = SDL_FALSE;
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask); SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask);

View File

@ -2913,18 +2913,8 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params); void (APIENTRY *glGetFramebufferAttachmentParameterivFunc) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
GLenum attachment = GL_BACK_LEFT; GLenum attachment = GL_BACK_LEFT;
GLenum attachmentattrib = 0; GLenum attachmentattrib = 0;
glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
if (!glGetStringFunc) {
return SDL_SetError("Failed getting OpenGL glGetString entry point");
}
#endif #endif
glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
if (!glGetErrorFunc) {
return SDL_SetError("Failed getting OpenGL glGetError entry point");
}
/* Clear value in any case */ /* Clear value in any case */
*value = 0; *value = 0;
@ -3095,6 +3085,11 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
} }
#if SDL_VIDEO_OPENGL #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))) { if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv"); 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(); error = glGetErrorFunc();
if (error != GL_NO_ERROR) { if (error != GL_NO_ERROR) {
if (error == GL_INVALID_ENUM) { if (error == GL_INVALID_ENUM) {