From a0519dc37d580d21f6190dc47e739d99ada09b71 Mon Sep 17 00:00:00 2001 From: pouillot Date: Tue, 3 May 2011 13:07:30 +0000 Subject: [PATCH] Re #320 Fixes the detection of max multi-sampling level under Windows git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3537 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: f650456ced9d536359cc929b87430418e1c2823b Former-commit-id: 207c34a230730a56612c1bb1891b6ba065d3b6cf --- src/libs/tgfclient/glfeatures.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/libs/tgfclient/glfeatures.cpp b/src/libs/tgfclient/glfeatures.cpp index 98964b3d4..841c7dfbd 100644 --- a/src/libs/tgfclient/glfeatures.cpp +++ b/src/libs/tgfclient/glfeatures.cpp @@ -16,18 +16,17 @@ * * ***************************************************************************/ - #include #include #include -//#include "guiscreen.h" #include "glfeatures.h" // Avoid C lib "max" to overload ones. #undef min + static const char* pszNoUnit = 0; @@ -204,12 +203,33 @@ bool GfglFeatures::detectBestSupport(int& nWidth, int& nHeight, int& nDepth, // Anti-aliasing : detect the max supported number of samples // (assumed to be <= 32). +#ifndef WIN32 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); +#endif int nMaxMultiSamples = 32; // Hard coded max value for the moment. while (!pWinSurface && nMaxMultiSamples > 1) { + // Set the anti-aliasing attributes and setup the video mode. +#ifdef WIN32 + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); +#endif SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, nMaxMultiSamples); pWinSurface = SDL_SetVideoMode(nWidth, nHeight, nCurrDepth, bfVideoMode); + + // Now check if we have a video mode, and if it actually features + // what we specified. +#ifdef WIN32 + int nActualSampleBuffers = 0; + SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &nActualSampleBuffers); + int nActualMultiSamples = 0; + SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &nActualMultiSamples); +// GfLogDebug("nMaxMultiSamples=%d : nActualSampleBuffers=%d, nActualMultiSamples=%d\n", +// nMaxMultiSamples, nActualSampleBuffers, nActualMultiSamples); + + // If not, try a lower number of samples. + if (nActualSampleBuffers == 0 || nActualMultiSamples != nMaxMultiSamples) + pWinSurface = 0; +#endif if (!pWinSurface) { GfLogTrace("%d+%d bit %dx anti-aliased double-buffer not supported\n", @@ -269,9 +289,11 @@ bool GfglFeatures::detectBestSupport(int& nWidth, int& nHeight, int& nDepth, int nValue; SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &nValue); _mapSupportedBool[MultiSampling] = nValue != 0; + //GfLogDebug("SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS) = %d\n", nValue); if (nValue) { SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &nValue); + //GfLogDebug("SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES) = %d\n", nValue); if (nValue > 1) _mapSupportedInt[MultiSamplingSamples] = nValue; else