I've written minimal program to display an image:
int main()
{
sf::Texture texture;
texture.loadFromFile("foo.jpg");
sf::Sprite sprite(texture);
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "foo");
window.draw(sprite);
window.display();
usleep(1000000);
return EXIT_SUCCESS;
}
This doesn't display anything. Of course, when I replace usleep with:
sf::Event event;
while (window.isOpen())
{
window.waitEvent(event);
}
I can see my picture. However, when I omit the call to window.waitEvent(), I don't see anything again. Calling only window.waitEvent(), not inside the window.isOpen() loop, doesn't display anything either.
My question is why? Is window.isOpen() or window.waitEvent() doing something hidden in the background that is neccessary to display anything?