Cleaned up WGL_ACCELERATION_ARB usage.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 11 Jul 2013 12:17:13 -0400
changeset 7401698995795574
parent 7400 243dad4e5f29
child 7402 235c9aaeefd1
Cleaned up WGL_ACCELERATION_ARB usage.

We now do FULL or NO accel based on the app's preference. If the app didn't
specify, we do FULL then fall back to NO.

(Not specifying anything--a true "don't care" scenario--breaks some ATI
drivers, so we try to keep to the spirit of it while forcing a specific
state.)

Previously, it would always do FULL, and try NO if it failed and the app
had requested NO or DONTCARE.

This is a transplant of hg changesets a04171d6fa11 and d0b7c45e982e from the
SDL-1.2 branch.

Fixes Bugzilla #1254.
src/video/windows/SDL_windowsopengl.c
     1.1 --- a/src/video/windows/SDL_windowsopengl.c	Thu Jul 11 01:09:45 2013 -0400
     1.2 +++ b/src/video/windows/SDL_windowsopengl.c	Thu Jul 11 12:17:13 2013 -0400
     1.3 @@ -425,6 +425,7 @@
     1.4      int pixel_format = 0;
     1.5      int iAttribs[64];
     1.6      int *iAttr;
     1.7 +    int *iAccelAttr;
     1.8      float fAttribs[1] = { 0 };
     1.9  
    1.10      WIN_GL_SetupPixelFormat(_this, &pfd);
    1.11 @@ -492,18 +493,28 @@
    1.12          *iAttr++ = _this->gl_config.multisamplesamples;
    1.13      }
    1.14  
    1.15 +    /* We always choose either FULL or NO accel on Windows, because of flaky
    1.16 +       drivers. If the app didn't specify, we use FULL, because that's
    1.17 +       probably what they wanted (and if you didn't care and got FULL, that's
    1.18 +       a perfectly valid result in any case). */
    1.19      *iAttr++ = WGL_ACCELERATION_ARB;
    1.20 -    *iAttr++ = WGL_FULL_ACCELERATION_ARB;
    1.21 +    iAccelAttr = iAttr;
    1.22 +    if (_this->gl_config.accelerated) {
    1.23 +        *iAttr++ = WGL_FULL_ACCELERATION_ARB;
    1.24 +    } else {
    1.25 +        *iAttr++ = WGL_NO_ACCELERATION_ARB;
    1.26 +    }
    1.27  
    1.28      *iAttr = 0;
    1.29  
    1.30      /* Choose and set the closest available pixel format */
    1.31 -    if (_this->gl_config.accelerated != 0) {
    1.32 +    pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
    1.33 +
    1.34 +    /* App said "don't care about accel" and FULL accel failed. Try NO. */
    1.35 +    if ( ( !pixel_format ) && ( _this->gl_config.accelerated < 0 ) ) {
    1.36 +        *iAccelAttr = WGL_NO_ACCELERATION_ARB;
    1.37          pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
    1.38 -    }
    1.39 -    if (!pixel_format && _this->gl_config.accelerated != 1) {
    1.40 -        iAttr[-1] = WGL_NO_ACCELERATION_ARB;
    1.41 -    pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
    1.42 +        *iAccelAttr = WGL_FULL_ACCELERATION_ARB;  /* if we try again. */
    1.43      }
    1.44      if (!pixel_format) {
    1.45          pixel_format = WIN_GL_ChoosePixelFormat(hdc, &pfd);