Setting one of the context settings' attributes to one that will fail causes an error message to be displayed. I don't think it's always been like this; to quote the
documentation for sf::ContextSettings:
No failure will be reported if one or more of these values are not supported by the system; instead, SFML will try to find the closest valid match.
which obviously isn't true anymore.
Is there, at least, a way to suppress this error message? Preferably, at least for release mode.Here's some short code that now causes the error message to be shown:
#include <SFML/Graphics.hpp>
int main()
{
sf::ContextSettings contextSettings;
contextSettings.antialiasingLevel = 128; // changing just one unsuccessful setting can make SFML display an error message
sf::RenderWindow window(sf::VideoMode(800, 600), "Context Settings", sf::Style::Default, contextSettings);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.display();
}
return EXIT_SUCCESS;
}
Error message (on my computer):
Warning: The created OpenGL context does not fully meet the settings that were requested
Requested: version = 1.1 ; depth bits = 0 ; stencil bits = 0 ; AA level = 128 ; core = false ; debug = false
Created: version = 4.2 ; depth bits = 24 ; stencil bits = 8 ; AA level = 4 ; core = false ; debug = false
I intentionally overshot the anti-alias maximum value by using an impossibly high value but it works the same if you overshoot it by anything (e.g. on my computer, trying 8). Overshooting seemed to be the solution previously due to not knowing the maximum (anti-alias level) it could achieve.
Commenting out the anti-aliasing assignment stops the error message as ContextSettings having default values for all of its attributes will cause it to find a match with no error message.
This also brings up another question: is it possible to disable the stencil buffer - or depth buffer - (as mentioned in
this tutorial) as it requires the stencil bits to be set to zero but this is ContextSettings' default value and finds a match (see error message above).
EDIT: Turns out that for depthBits and stencilBits, anything lower will be 'promoted' while anything higher will cause the same error message.