Fixed bug 1161 (Setting GL_ACCELERATED_VISUAL to 1 forces software rendering in Windows XP)
authorSam Lantinga <slouken@libsdl.org>
Mon, 07 Mar 2011 14:06:46 -0800
changeset 54466ac8b0ac645e
parent 5445 b2bcc3c36fa3
child 5447 2a3cf6d7cac5
Fixed bug 1161 (Setting GL_ACCELERATED_VISUAL to 1 forces software rendering in Windows XP)

Jesse Anders 2011-03-05 23:30:09 PST

It seems that in Windows XP, setting SDL_GL_ACCELERATED_VISUAL to 1 actually
disables hardware acceleration and puts OpenGL in software mode.

In the source code, the corresponding WGL attribute is first set here:

*iAttr++ = WGL_ACCELERATION_ARB;
*iAttr++ = WGL_FULL_ACCELERATION_ARB;

Later, this code:

if (_this->gl_config.accelerated >= 0) {
*iAttr++ = WGL_ACCELERATION_ARB;
*iAttr++ =
(_this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB :
WGL_NO_ACCELERATION_ARB);
}

Sets it again if SDL_GL_ACCELERATED_VISUAL has a value other than the default.

More importantly, the documentation I found states that
WGL_GENERIC_ACCELERATION_ARB asks for an MDC driver, which, although I don't
know much about this topic, doesn't seem like the correct choice here. As
mentioned previously, the end effect is that requesting hardware acceleration
in Windows XP actually forces the renderer into software mode (on my system at
least), which I'm guessing isn't the desired behavior.
src/video/windows/SDL_windowsopengl.c
     1.1 --- a/src/video/windows/SDL_windowsopengl.c	Mon Mar 07 09:58:21 2011 -0800
     1.2 +++ b/src/video/windows/SDL_windowsopengl.c	Mon Mar 07 14:06:46 2011 -0800
     1.3 @@ -409,8 +409,6 @@
     1.4  
     1.5      *iAttr++ = WGL_DRAW_TO_WINDOW_ARB;
     1.6      *iAttr++ = GL_TRUE;
     1.7 -    *iAttr++ = WGL_ACCELERATION_ARB;
     1.8 -    *iAttr++ = WGL_FULL_ACCELERATION_ARB;
     1.9      *iAttr++ = WGL_RED_BITS_ARB;
    1.10      *iAttr++ = _this->gl_config.red_size;
    1.11      *iAttr++ = WGL_GREEN_BITS_ARB;
    1.12 @@ -469,12 +467,9 @@
    1.13          *iAttr++ = _this->gl_config.multisamplesamples;
    1.14      }
    1.15  
    1.16 -    if (_this->gl_config.accelerated >= 0) {
    1.17 -        *iAttr++ = WGL_ACCELERATION_ARB;
    1.18 -        *iAttr++ =
    1.19 -            (_this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB :
    1.20 -             WGL_NO_ACCELERATION_ARB);
    1.21 -    }
    1.22 +    *iAttr++ = WGL_ACCELERATION_ARB;
    1.23 +    *iAttr++ = (_this->gl_config.accelerated ? WGL_FULL_ACCELERATION_ARB :
    1.24 +                                               WGL_NO_ACCELERATION_ARB);
    1.25  
    1.26      *iAttr = 0;
    1.27