Improved the anti-aliasing level selection algorithm

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1316 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-01-02 13:42:32 +00:00
parent 6d717f3c87
commit f2a1ba3cda

View File

@ -174,26 +174,14 @@ void ContextWGL::CreateContext(ContextWGL* shared, unsigned int bitsPerPixel, co
UINT nbFormats; UINT nbFormats;
float floatAttributes[] = {0, 0}; float floatAttributes[] = {0, 0};
bool isValid = wglChoosePixelFormatARB(myDeviceContext, intAttributes, floatAttributes, sizeof(formats) / sizeof(*formats), formats, &nbFormats) != 0; bool isValid = wglChoosePixelFormatARB(myDeviceContext, intAttributes, floatAttributes, sizeof(formats) / sizeof(*formats), formats, &nbFormats) != 0;
if (!isValid || (nbFormats == 0)) while ((!isValid || (nbFormats == 0)) && mySettings.AntialiasingLevel > 0)
{ {
if (mySettings.AntialiasingLevel > 2) // Decrease the antialiasing level until we find a valid one
{ mySettings.AntialiasingLevel--;
// No format matching our needs : reduce the multisampling level intAttributes[11] = mySettings.AntialiasingLevel;
std::cerr << "Failed to find a pixel format supporting "
<< mySettings.AntialiasingLevel << " antialiasing levels ; trying with 2 levels" << std::endl;
mySettings.AntialiasingLevel = intAttributes[11] = 2;
isValid = wglChoosePixelFormatARB(myDeviceContext, intAttributes, floatAttributes, sizeof(formats) / sizeof(*formats), formats, &nbFormats) != 0; isValid = wglChoosePixelFormatARB(myDeviceContext, intAttributes, floatAttributes, sizeof(formats) / sizeof(*formats), formats, &nbFormats) != 0;
} }
if (!isValid || (nbFormats == 0))
{
// Cannot find any pixel format supporting multisampling ; disabling antialiasing
std::cerr << "Failed to find a pixel format supporting antialiasing ; antialiasing will be disabled" << std::endl;
mySettings.AntialiasingLevel = 0;
}
}
// Get the best format among the returned ones // Get the best format among the returned ones
if (isValid && (nbFormats > 0)) if (isValid && (nbFormats > 0))
{ {