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.
--- a/src/video/windows/SDL_windowsopengl.c Thu Jul 11 01:09:45 2013 -0400
+++ b/src/video/windows/SDL_windowsopengl.c Thu Jul 11 12:17:13 2013 -0400
@@ -425,6 +425,7 @@
int pixel_format = 0;
int iAttribs[64];
int *iAttr;
+ int *iAccelAttr;
float fAttribs[1] = { 0 };
WIN_GL_SetupPixelFormat(_this, &pfd);
@@ -492,18 +493,28 @@
*iAttr++ = _this->gl_config.multisamplesamples;
}
+ /* We always choose either FULL or NO accel on Windows, because of flaky
+ drivers. If the app didn't specify, we use FULL, because that's
+ probably what they wanted (and if you didn't care and got FULL, that's
+ a perfectly valid result in any case). */
*iAttr++ = WGL_ACCELERATION_ARB;
- *iAttr++ = WGL_FULL_ACCELERATION_ARB;
+ iAccelAttr = iAttr;
+ if (_this->gl_config.accelerated) {
+ *iAttr++ = WGL_FULL_ACCELERATION_ARB;
+ } else {
+ *iAttr++ = WGL_NO_ACCELERATION_ARB;
+ }
*iAttr = 0;
/* Choose and set the closest available pixel format */
- if (_this->gl_config.accelerated != 0) {
+ pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
+
+ /* App said "don't care about accel" and FULL accel failed. Try NO. */
+ if ( ( !pixel_format ) && ( _this->gl_config.accelerated < 0 ) ) {
+ *iAccelAttr = WGL_NO_ACCELERATION_ARB;
pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
- }
- if (!pixel_format && _this->gl_config.accelerated != 1) {
- iAttr[-1] = WGL_NO_ACCELERATION_ARB;
- pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
+ *iAccelAttr = WGL_FULL_ACCELERATION_ARB; /* if we try again. */
}
if (!pixel_format) {
pixel_format = WIN_GL_ChoosePixelFormat(hdc, &pfd);