Is it possible to utilize a thread mainly for handling the close button of the application window? My current code doesn't seem to work. The window just freezes as if I wasn't checking for events, although the thread is running.
#include <SFML/Graphics.hpp>
//#include <game.hpp>
sf::RenderWindow appWindow( sf::VideoMode( 800,600 ),"Fox" );
void AppEvents()
{
while( appWindow.isOpen() )
{
sf::Event event;
while( appWindow.pollEvent( event ) )
{
if ( event.type == sf::Event::Closed )
appWindow.close();
}
}
}
int main(int argc, char* argv[])
{
//Player player;
//Room room("res/rooms/MainMenu/room.xml");
sf::Thread appEvents(&AppEvents);
appEvents.launch();
appEvents.wait();
return EXIT_SUCCESS;
}
Any body have an idea why that might be?