Add SDL_GL_ResetAttributes.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Wed, 29 Jan 2014 18:38:13 -0800
changeset 8145663d7d9de9bf
parent 8144 855b1d6d7d8e
child 8146 bfff4df36f0b
Add SDL_GL_ResetAttributes.
include/SDL_video.h
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
src/video/SDL_video.c
     1.1 --- a/include/SDL_video.h	Thu Jan 30 12:30:40 2014 -0800
     1.2 +++ b/include/SDL_video.h	Wed Jan 29 18:38:13 2014 -0800
     1.3 @@ -866,6 +866,11 @@
     1.4                                                             *extension);
     1.5  
     1.6  /**
     1.7 + *  \brief Reset all previously set OpenGL context attributes to their default values
     1.8 + */
     1.9 +extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
    1.10 +
    1.11 +/**
    1.12   *  \brief Set an OpenGL window attribute before window creation.
    1.13   */
    1.14  extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
     2.1 --- a/src/dynapi/SDL_dynapi_overrides.h	Thu Jan 30 12:30:40 2014 -0800
     2.2 +++ b/src/dynapi/SDL_dynapi_overrides.h	Wed Jan 29 18:38:13 2014 -0800
     2.3 @@ -570,3 +570,4 @@
     2.4  #define SDL_GL_DeleteContext SDL_GL_DeleteContext_REAL
     2.5  #define SDL_vsscanf SDL_vsscanf_REAL
     2.6  #define SDL_GameControllerAddMappingsFromRW SDL_GameControllerAddMappingsFromRW_REAL
     2.7 +#define SDL_GL_ResetAttributes SDL_GL_ResetAttributes_REAL
     3.1 --- a/src/dynapi/SDL_dynapi_procs.h	Thu Jan 30 12:30:40 2014 -0800
     3.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Wed Jan 29 18:38:13 2014 -0800
     3.3 @@ -599,3 +599,4 @@
     3.4  SDL_DYNAPI_PROC(void,SDL_GL_DeleteContext,(SDL_GLContext a),(a),)
     3.5  SDL_DYNAPI_PROC(int,SDL_vsscanf,(const char *a, const char *b, va_list c),(a,b,c),return)
     3.6  SDL_DYNAPI_PROC(int,SDL_GameControllerAddMappingsFromRW,(SDL_RWops *a, int b),(a,b),return)
     3.7 +SDL_DYNAPI_PROC(void,SDL_GL_ResetAttributes,(void),(),)
     4.1 --- a/src/video/SDL_video.c	Thu Jan 30 12:30:40 2014 -0800
     4.2 +++ b/src/video/SDL_video.c	Wed Jan 29 18:38:13 2014 -0800
     4.3 @@ -477,39 +477,7 @@
     4.4      /* Set some very sane GL defaults */
     4.5      _this->gl_config.driver_loaded = 0;
     4.6      _this->gl_config.dll_handle = NULL;
     4.7 -    _this->gl_config.red_size = 3;
     4.8 -    _this->gl_config.green_size = 3;
     4.9 -    _this->gl_config.blue_size = 2;
    4.10 -    _this->gl_config.alpha_size = 0;
    4.11 -    _this->gl_config.buffer_size = 0;
    4.12 -    _this->gl_config.depth_size = 16;
    4.13 -    _this->gl_config.stencil_size = 0;
    4.14 -    _this->gl_config.double_buffer = 1;
    4.15 -    _this->gl_config.accum_red_size = 0;
    4.16 -    _this->gl_config.accum_green_size = 0;
    4.17 -    _this->gl_config.accum_blue_size = 0;
    4.18 -    _this->gl_config.accum_alpha_size = 0;
    4.19 -    _this->gl_config.stereo = 0;
    4.20 -    _this->gl_config.multisamplebuffers = 0;
    4.21 -    _this->gl_config.multisamplesamples = 0;
    4.22 -    _this->gl_config.retained_backing = 1;
    4.23 -    _this->gl_config.accelerated = -1;  /* accelerated or not, both are fine */
    4.24 -    _this->gl_config.profile_mask = 0;
    4.25 -#if SDL_VIDEO_OPENGL
    4.26 -    _this->gl_config.major_version = 2;
    4.27 -    _this->gl_config.minor_version = 1;
    4.28 -#elif SDL_VIDEO_OPENGL_ES2
    4.29 -    _this->gl_config.major_version = 2;
    4.30 -    _this->gl_config.minor_version = 0;
    4.31 -    _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;   
    4.32 -#elif SDL_VIDEO_OPENGL_ES
    4.33 -    _this->gl_config.major_version = 1;
    4.34 -    _this->gl_config.minor_version = 1;
    4.35 -    _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
    4.36 -#endif
    4.37 -    _this->gl_config.flags = 0;
    4.38 -    
    4.39 -    _this->gl_config.share_with_current_context = 0;
    4.40 +    SDL_GL_ResetAttributes();
    4.41  
    4.42      _this->current_glwin_tls = SDL_TLSCreate();
    4.43      _this->current_glctx_tls = SDL_TLSCreate();
    4.44 @@ -2547,6 +2515,49 @@
    4.45  #endif
    4.46  }
    4.47  
    4.48 +void
    4.49 +SDL_GL_ResetAttributes()
    4.50 +{
    4.51 +    if (!_this) {
    4.52 +        return;
    4.53 +    }
    4.54 +
    4.55 +    _this->gl_config.red_size = 3;
    4.56 +    _this->gl_config.green_size = 3;
    4.57 +    _this->gl_config.blue_size = 2;
    4.58 +    _this->gl_config.alpha_size = 0;
    4.59 +    _this->gl_config.buffer_size = 0;
    4.60 +    _this->gl_config.depth_size = 16;
    4.61 +    _this->gl_config.stencil_size = 0;
    4.62 +    _this->gl_config.double_buffer = 1;
    4.63 +    _this->gl_config.accum_red_size = 0;
    4.64 +    _this->gl_config.accum_green_size = 0;
    4.65 +    _this->gl_config.accum_blue_size = 0;
    4.66 +    _this->gl_config.accum_alpha_size = 0;
    4.67 +    _this->gl_config.stereo = 0;
    4.68 +    _this->gl_config.multisamplebuffers = 0;
    4.69 +    _this->gl_config.multisamplesamples = 0;
    4.70 +    _this->gl_config.retained_backing = 1;
    4.71 +    _this->gl_config.accelerated = -1;  /* accelerated or not, both are fine */
    4.72 +    _this->gl_config.profile_mask = 0;
    4.73 +#if SDL_VIDEO_OPENGL
    4.74 +    _this->gl_config.major_version = 2;
    4.75 +    _this->gl_config.minor_version = 1;
    4.76 +#elif SDL_VIDEO_OPENGL_ES2
    4.77 +    _this->gl_config.major_version = 2;
    4.78 +    _this->gl_config.minor_version = 0;
    4.79 +    _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
    4.80 +#elif SDL_VIDEO_OPENGL_ES
    4.81 +    _this->gl_config.major_version = 1;
    4.82 +    _this->gl_config.minor_version = 1;
    4.83 +    _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
    4.84 +#endif
    4.85 +    _this->gl_config.flags = 0;
    4.86 +    _this->gl_config.framebuffer_srgb_capable = 0;
    4.87 +
    4.88 +    _this->gl_config.share_with_current_context = 0;
    4.89 +}
    4.90 +
    4.91  int
    4.92  SDL_GL_SetAttribute(SDL_GLattr attr, int value)
    4.93  {