Hey
I try to create sf::RenderTexture object in std::thread method and it causes stack overflow.
My code:
#include <SFML/Graphics.hpp>
#include <thread>
int main()
{
sf::RenderTexture texture;
std::thread thread([]() {
sf::RenderTexture t;
});
thread.join();
return 0;
}
Without creating first texture it happens too.
#include <SFML/Graphics.hpp>
#include <thread>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "WINDOW");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::MouseButtonPressed)//crash when button is pressed
{
std::thread thread([]() {
sf::RenderTexture t;
});
}
}
window.clear(sf::Color(50, 50, 50));
window.display();
}
return 0;
}
but it doesn't crash with this code:
#include <SFML/Graphics.hpp>
#include <thread>
int main()
{
std::thread thread([]() {
sf::RenderTexture t;
});
thread.join();
return 0;
}
How to solve this problem?
SFML 2.4.2
Microsoft Visual Studio Community 2015, Version 14