mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
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:
parent
6d717f3c87
commit
f2a1ba3cda
@ -174,26 +174,14 @@ void ContextWGL::CreateContext(ContextWGL* shared, unsigned int bitsPerPixel, co
|
||||
UINT nbFormats;
|
||||
float floatAttributes[] = {0, 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)
|
||||
{
|
||||
// No format matching our needs : reduce the multisampling level
|
||||
std::cerr << "Failed to find a pixel format supporting "
|
||||
<< mySettings.AntialiasingLevel << " antialiasing levels ; trying with 2 levels" << std::endl;
|
||||
|
||||
mySettings.AntialiasingLevel = intAttributes[11] = 2;
|
||||
// Decrease the antialiasing level until we find a valid one
|
||||
mySettings.AntialiasingLevel--;
|
||||
intAttributes[11] = mySettings.AntialiasingLevel;
|
||||
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
|
||||
if (isValid && (nbFormats > 0))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user