src/video/windows/SDL_windowsopengl.c
changeset 6393 a773384edf20
parent 6383 869effc44c41
child 6406 3a098f2d4dea
     1.1 --- a/src/video/windows/SDL_windowsopengl.c	Sat Aug 11 10:15:59 2012 -0700
     1.2 +++ b/src/video/windows/SDL_windowsopengl.c	Sun Aug 12 11:16:24 2012 -0700
     1.3 @@ -61,6 +61,11 @@
     1.4  #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT           0x00000004
     1.5  #endif
     1.6  
     1.7 +#ifndef WGL_EXT_create_context_es_profile
     1.8 +#define WGL_EXT_create_context_es_profile
     1.9 +#define WGL_CONTEXT_ES_PROFILE_BIT_EXT            0x00000004
    1.10 +#endif
    1.11 +
    1.12  typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC,
    1.13                                                              HGLRC
    1.14                                                              hShareContext,
    1.15 @@ -112,6 +117,8 @@
    1.16          GetProcAddress(handle, "wglDeleteContext");
    1.17      _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC))
    1.18          GetProcAddress(handle, "wglMakeCurrent");
    1.19 +    _this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC))
    1.20 +        GetProcAddress(handle, "wglShareLists");
    1.21  
    1.22      if (!_this->gl_data->wglGetProcAddress ||
    1.23          !_this->gl_data->wglCreateContext ||
    1.24 @@ -519,10 +526,22 @@
    1.25  WIN_GL_CreateContext(_THIS, SDL_Window * window)
    1.26  {
    1.27      HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
    1.28 -    HGLRC context;
    1.29 +    HGLRC context, share_context;
    1.30  
    1.31 -    if (_this->gl_config.major_version < 3) {
    1.32 +    if (_this->gl_config.share_with_current_context) {
    1.33 +        share_context = (HGLRC)(_this->current_glctx);
    1.34 +    } else {
    1.35 +        share_context = 0;
    1.36 +    }
    1.37 +
    1.38 +    if (_this->gl_config.major_version < 3 &&
    1.39 +	_this->gl_config.profile_mask == 0 &&
    1.40 +	_this->gl_config.flags == 0) {
    1.41 +        /* Create legacy context */
    1.42          context = _this->gl_data->wglCreateContext(hdc);
    1.43 +	if( share_context != 0 ) {
    1.44 +            _this->gl_data->wglShareLists(share_context, hdc);
    1.45 +	}
    1.46      } else {
    1.47          PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
    1.48          HGLRC temp_context = _this->gl_data->wglCreateContext(hdc);
    1.49 @@ -567,7 +586,7 @@
    1.50  	    attribs[iattr++] = 0;
    1.51  
    1.52              /* Create the GL 3.x context */
    1.53 -            context = wglCreateContextAttribsARB(hdc, 0, attribs);
    1.54 +            context = wglCreateContextAttribsARB(hdc, share_context, attribs);
    1.55              /* Delete the GL 2.x context */
    1.56              _this->gl_data->wglDeleteContext(temp_context);
    1.57          }