Still a slight problem:
bool splash_running;
void splash(void *);
int main()
{
window.create(800, 600, 32, "Window");
sf::Thread splash_thread(&splash);
splash_thread.Launch();
//load();
splash_running = false;
splash_thread.Wait();
bool running = true;
while (running)
{
window.event(&running);
window.draw();
}
return 0;
}
void splash(void *)
{
int width = 200;
int height = 120;
sf::Window *splash = new sf::Window(sf::VideoMode(width, height, 32), "Loading...");
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, width, height, 0.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
splash_running = true;
while (splash_running)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_QUADS);
glVertex2d(0, 0);
glVertex2d(width, 0);
glVertex2d(width, height);
glVertex2d(0, height);
glEnd();
splash->Display();
sf::Sleep(0.001);
}
delete splash;
}
This sometimes works and sometimes does not. The problem is that the splash thread opens up including the main window, but the thread never stops the display loop. It keeps going and I have to use Ctrl+Alt+Del to shut the program.
Perhaps I should use mutexes, but the tutorial says that that's not needed for boolean operations...