diff --git a/include/SDL_video.h b/include/SDL_video.h index 4a53f9b34..414d26aa2 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -865,6 +865,11 @@ extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char *extension); +/** + * \brief Reset all previously set OpenGL context attributes to their default values + */ +extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void); + /** * \brief Set an OpenGL window attribute before window creation. */ diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 613582d1d..f58dde0fe 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -570,3 +570,4 @@ #define SDL_GL_DeleteContext SDL_GL_DeleteContext_REAL #define SDL_vsscanf SDL_vsscanf_REAL #define SDL_GameControllerAddMappingsFromRW SDL_GameControllerAddMappingsFromRW_REAL +#define SDL_GL_ResetAttributes SDL_GL_ResetAttributes_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index cf34efc95..8291d2284 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -599,3 +599,4 @@ SDL_DYNAPI_PROC(void,SDL_GL_SwapWindow,(SDL_Window *a),(a),) SDL_DYNAPI_PROC(void,SDL_GL_DeleteContext,(SDL_GLContext a),(a),) SDL_DYNAPI_PROC(int,SDL_vsscanf,(const char *a, const char *b, va_list c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_GameControllerAddMappingsFromRW,(SDL_RWops *a, int b),(a,b),return) +SDL_DYNAPI_PROC(void,SDL_GL_ResetAttributes,(void),(),) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 157cfa9e7..2e20feabe 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -477,39 +477,7 @@ SDL_VideoInit(const char *driver_name) /* Set some very sane GL defaults */ _this->gl_config.driver_loaded = 0; _this->gl_config.dll_handle = NULL; - _this->gl_config.red_size = 3; - _this->gl_config.green_size = 3; - _this->gl_config.blue_size = 2; - _this->gl_config.alpha_size = 0; - _this->gl_config.buffer_size = 0; - _this->gl_config.depth_size = 16; - _this->gl_config.stencil_size = 0; - _this->gl_config.double_buffer = 1; - _this->gl_config.accum_red_size = 0; - _this->gl_config.accum_green_size = 0; - _this->gl_config.accum_blue_size = 0; - _this->gl_config.accum_alpha_size = 0; - _this->gl_config.stereo = 0; - _this->gl_config.multisamplebuffers = 0; - _this->gl_config.multisamplesamples = 0; - _this->gl_config.retained_backing = 1; - _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */ - _this->gl_config.profile_mask = 0; -#if SDL_VIDEO_OPENGL - _this->gl_config.major_version = 2; - _this->gl_config.minor_version = 1; -#elif SDL_VIDEO_OPENGL_ES2 - _this->gl_config.major_version = 2; - _this->gl_config.minor_version = 0; - _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; -#elif SDL_VIDEO_OPENGL_ES - _this->gl_config.major_version = 1; - _this->gl_config.minor_version = 1; - _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; -#endif - _this->gl_config.flags = 0; - - _this->gl_config.share_with_current_context = 0; + SDL_GL_ResetAttributes(); _this->current_glwin_tls = SDL_TLSCreate(); _this->current_glctx_tls = SDL_TLSCreate(); @@ -2547,6 +2515,49 @@ SDL_GL_ExtensionSupported(const char *extension) #endif } +void +SDL_GL_ResetAttributes() +{ + if (!_this) { + return; + } + + _this->gl_config.red_size = 3; + _this->gl_config.green_size = 3; + _this->gl_config.blue_size = 2; + _this->gl_config.alpha_size = 0; + _this->gl_config.buffer_size = 0; + _this->gl_config.depth_size = 16; + _this->gl_config.stencil_size = 0; + _this->gl_config.double_buffer = 1; + _this->gl_config.accum_red_size = 0; + _this->gl_config.accum_green_size = 0; + _this->gl_config.accum_blue_size = 0; + _this->gl_config.accum_alpha_size = 0; + _this->gl_config.stereo = 0; + _this->gl_config.multisamplebuffers = 0; + _this->gl_config.multisamplesamples = 0; + _this->gl_config.retained_backing = 1; + _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */ + _this->gl_config.profile_mask = 0; +#if SDL_VIDEO_OPENGL + _this->gl_config.major_version = 2; + _this->gl_config.minor_version = 1; +#elif SDL_VIDEO_OPENGL_ES2 + _this->gl_config.major_version = 2; + _this->gl_config.minor_version = 0; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; +#elif SDL_VIDEO_OPENGL_ES + _this->gl_config.major_version = 1; + _this->gl_config.minor_version = 1; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; +#endif + _this->gl_config.flags = 0; + _this->gl_config.framebuffer_srgb_capable = 0; + + _this->gl_config.share_with_current_context = 0; +} + int SDL_GL_SetAttribute(SDL_GLattr attr, int value) {