Hi all,
I'm having a problem where initializing anything that uses a
GLResource causes a stack overflow when initialized on a separate thread:
#include <SFML/Graphics.hpp>
int main()
{
sf::Window w;
auto thread = std::thread{ []
{
sf::Texture t; // Stack overflow occurs here
}};
thread.join();
return 0;
}
What happens here is:
Texture::Texture() calls
GlResource::GlResource(), which calls
GlContext::ensureContext(), which calls
GlContext::getInternalContext(), which calls
Context::Context() (trying to create an internal context), which calls
GlResource::GlResource(), and now we're in an infinite loop.
I know threading is a Bad Thing™, but in order to have smooth window resizing
events and drawing need to happen on separate threads, and
you can only pump events from the thread that created the window. So I need to create a window and poll its events in thread #1, and draw to it in thread #2. Creating the window and drawing to the window both use
GLResources, but I'm running into the error above. If anyone could shed some light on this issue I'd be very grateful.