Hello i'm new in SFML, I want to draw sprite from another thread so i created thread:
void DrawMap(RenderWindow * render_window)
{
while (true)
{
for (int y = 0; y < 5; y++)
{
for (int x = 0; x < 10; x++)
{
face_img.setTextureRect(IntRect(rand() % 3 * 32, 0, 32, 32));
face_img.setPosition(x * 64, y * 64);
render_window->draw(face_img);
}
}
Sleep(100);
}
}
In main() i have created RenderWindow:
RenderWindow render_window(VideoMode(640, 320), "Map Generator", Style::Close + Style::Titlebar);
And I started the thread:
Thread thread(&DrawMap, &render_window);
thread.launch();
But nothing was drawed, i have message: "Failed to activate window's context"
Please help, and sorry I'm sure that my error is stupid but I'm new here.
Thanks!