I want a console application that is able to create some small sfml-windows that appear next to the console.
My idea was to leave logical computations together with console io in the main thread and to create a new thread for each external window to handle events etc.
I tried things like:
void spawn()
{
sf::RenderWindow w(sf::VideoMode(400, 400), "external");
w.setActive(true);
while (w.isOpen())
{
sf::Event event;
while (w.pollEvent(event))
if (event.type == sf::Event::Closed)
w.close();
w.clear();
w.display();
}
}
void main()
{
std::thread(&spawn).detach();
std::thread(&spawn).detach();
std::cin.get();
}
I also experimented with creating the window in the main thread and passing it to the functions (with deactivating it before).
However, as soon as I try to spawn more than one external window, I always get an stack overflow error.
Is it possible to handle multiple windows like that? What am I missing here?
Thanks.