From d64f776a9a41a8d1144397b7b62efbdee8d24857 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 31 Mar 2015 09:17:39 +0200 Subject: [PATCH] Windows: Fallback to 0 samples if ARB::choosePixelFormat() fails with 1 This solves a problem when using a Qt application over remote desktop as if it failed with even 1 sample then it would fallback to GDI which causes an error if the software OpenGL option is used. Change-Id: Ib311a7a657f92aab15277461bc8e040bebbe4753 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsglcontext.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index 3348241d37..908bc65843 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -597,6 +597,14 @@ static int choosePixelFormat(HDC hdc, break; if (iAttributes[samplesValuePosition] > 1) { iAttributes[samplesValuePosition] /= 2; + } else if (iAttributes[samplesValuePosition] == 1) { + // Fallback in case it is unable to initialize with any + // samples to avoid falling back to the GDI path + // NB: The sample attributes needs to be at the end for this + // to work correctly + iAttributes[samplesValuePosition - 1] = FALSE; + iAttributes[samplesValuePosition] = 0; + iAttributes[samplesValuePosition + 1] = 0; } else { break; }