src/video/windows/SDL_windowsopengl.c
changeset 6296 b42657486c0d
parent 6138 4c64952a58fb
child 6380 3990b7d564d7
     1.1 --- a/src/video/windows/SDL_windowsopengl.c	Mon Feb 20 20:56:52 2012 -0500
     1.2 +++ b/src/video/windows/SDL_windowsopengl.c	Mon Feb 20 23:37:57 2012 -0500
     1.3 @@ -39,6 +39,26 @@
     1.4  #define WGL_CONTEXT_FLAGS_ARB           0x2093
     1.5  #define WGL_CONTEXT_DEBUG_BIT_ARB       0x0001
     1.6  #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB  0x0002
     1.7 +
     1.8 +#ifndef WGL_ARB_create_context_profile
     1.9 +#define WGL_ARB_create_context_profile
    1.10 +#define WGL_CONTEXT_PROFILE_MASK_ARB              0x9126
    1.11 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB          0x00000001
    1.12 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
    1.13 +#endif
    1.14 +
    1.15 +#ifndef WGL_ARB_create_context_robustness
    1.16 +#define WGL_ARB_create_context_robustness
    1.17 +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB         0x00000004
    1.18 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB     0x8256
    1.19 +#define WGL_NO_RESET_NOTIFICATION_ARB                   0x8261
    1.20 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB                   0x8252
    1.21 +#endif
    1.22 +#endif
    1.23 +
    1.24 +#ifndef WGL_EXT_create_context_es2_profile
    1.25 +#define WGL_EXT_create_context_es2_profile
    1.26 +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT           0x00000004
    1.27  #endif
    1.28  
    1.29  typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC,
    1.30 @@ -398,7 +418,7 @@
    1.31  {
    1.32      HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
    1.33      PIXELFORMATDESCRIPTOR pfd;
    1.34 -    int pixel_format;
    1.35 +    int pixel_format = 0;
    1.36      int iAttribs[64];
    1.37      int *iAttr;
    1.38      float fAttribs[1] = { 0 };
    1.39 @@ -468,16 +488,19 @@
    1.40          *iAttr++ = _this->gl_config.multisamplesamples;
    1.41      }
    1.42  
    1.43 -    if (_this->gl_config.accelerated >= 0) {
    1.44 -        *iAttr++ = WGL_ACCELERATION_ARB;
    1.45 -        *iAttr++ = (_this->gl_config.accelerated ? WGL_FULL_ACCELERATION_ARB :
    1.46 -                                                   WGL_NO_ACCELERATION_ARB);
    1.47 -    }
    1.48 +    *iAttr++ = WGL_ACCELERATION_ARB;
    1.49 +    *iAttr++ = WGL_FULL_ACCELERATION_ARB;
    1.50  
    1.51      *iAttr = 0;
    1.52  
    1.53      /* Choose and set the closest available pixel format */
    1.54 -    pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
    1.55 +    if (_this->gl_config.accelerated != 0) {
    1.56 +        pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
    1.57 +    }
    1.58 +    if (!pixel_format && _this->gl_config.accelerated != 1) {
    1.59 +        iAttr[-1] = WGL_NO_ACCELERATION_ARB;
    1.60 +	pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
    1.61 +    }
    1.62      if (!pixel_format) {
    1.63          pixel_format = WIN_GL_ChoosePixelFormat(hdc, &pfd);
    1.64      }
    1.65 @@ -521,11 +544,28 @@
    1.66              SDL_SetError("GL 3.x is not supported");
    1.67              context = temp_context;
    1.68          } else {
    1.69 -            int attribs[] = {
    1.70 +	    /* max 8 attributes plus terminator */
    1.71 +            int attribs[9] = {
    1.72                  WGL_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version,
    1.73                  WGL_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version,
    1.74                  0
    1.75              };
    1.76 +	    int iattr = 4;
    1.77 +
    1.78 +	    /* SDL profile bits match WGL profile bits */
    1.79 +	    if( _this->gl_config.profile_mask != 0 ) {
    1.80 +	        attribs[iattr++] = WGL_CONTEXT_PROFILE_MASK_ARB;
    1.81 +		attribs[iattr++] = _this->gl_config.profile_mask;
    1.82 +	    }
    1.83 +
    1.84 +	    /* SDL flags match WGL flags */
    1.85 +	    if( _this->gl_config.flags != 0 ) {
    1.86 +	        attribs[iattr++] = WGL_CONTEXT_FLAGS_ARB;
    1.87 +		attribs[iattr++] = _this->gl_config.flags;
    1.88 +	    }
    1.89 +
    1.90 +	    attribs[iattr++] = 0;
    1.91 +
    1.92              /* Create the GL 3.x context */
    1.93              context = wglCreateContextAttribsARB(hdc, 0, attribs);
    1.94              /* Delete the GL 2.x context */