I am writing a small image viewer and when I start my program it shows the image I loaded, flickers to black, and back to the image.
Strangely, when I set up my window to start on a secondary monitor the flickering goes away.
I filmed my left monitor (configured as the main display) while opening an image (for testing it's just a green BG) with my editor. A series of images of the launch (~200 ms):
http://i.imgur.com/s9jc8n7.pngAs you can see the screen starts out green but then flashes to black and back to green.
This is what it looks like when I set my other monitor (right) as the main display but make sure that the window is still being displayed on the left monitor using window.setPosition(sf::Vector2i(-1920, 0)).
http://i.imgur.com/F8W38I9.pngNo flickering.
I stripped down my code to this and it's still happening:
int main()
{
sf::RenderWindow window(sf::VideoMode(1920, 1080), "Test", sf::Style::None);
window.setPosition(sf::Vector2i(0, 0));
//window.setPosition(sf::Vector2i(-1920, 0));
//This would make it work for my left monitor if it were configured as a secondary display
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
return 0;
}
}
window.clear(sf::Color::Green);
window.display();
}
return 0;
}
Changing the window style to full screen doesn't help either.
If I were to offset the window by 1+ pixel, so that the task bar is overlapping the window, the issue is gone.
Is this a problem with full screen/borderless full screen (achieved with sf::style::None) on the main display, or just the expected behavior for such an application?