I'm using SFML 1.6 on XUbuntu LTS.
I like to get a second OpenGL context to run that shares resources with the render context, so I can use it to load stuff in the background.
My tests so far only got x11 to lockup and I hat to use magic keys to reboot. :{
My first try was to use sf::Context and create it after the real windows was created.
Then start a new thread and acticated the context there. As soon as the shader is marked as ready I try to use it in the main thread. Thats when I get the lockup.
I also tried this using the global shared context instead of my self created one.
How is this done right?
Some short non working example code:
Version where I use new created context
bool readyVariable = false;
sf::Context *context2;
void theThread(void* data)
{
context2->SetActive(true);
//... do some glsl compiling
//compiling here works like a charm... no errors all ok
readyVariable = true;
}
int main()
{
App.Create( sf::VideoMode(640, 480, 32), "SFML OpenGL", sf::Style::Resize | sf::Style::Close, sf::WindowSettings(24, 8, 0));
context2 = new sf::Context();
sf::Thread thread(&theThread);
thread.Launch();
while(true)
{
while(App.GetEvent(e))
{
processEvent(e);
}
if(!App.IsOpened()) break;
//Render insignificant stuff
if (readyVariable)
{
//try to use the glsl shader that is now compiled
//This will lockup x11
}
App.Display();
}
}
Version where I use the global context
bool readyVariable = false;
void theThread(void* data)
{
sf::Context::GetGlobal().SetActive(true);
//... do some glsl compiling
//compiling here works like a charm... no errors all ok
readyVariable = true;
}
int main()
{
App.Create( sf::VideoMode(640, 480, 32), "SFML OpenGL", sf::Style::Resize | sf::Style::Close, sf::WindowSettings(24, 8, 0));
sf::Thread thread(&theThread);
thread.Launch();
while(true)
{
while(App.GetEvent(e))
{
processEvent(e);
}
if(!App.IsOpened()) break;
//Render insignificant stuff
if (readyVariable)
{
//try to use the glsl shader that is now compiled
//This will lockup x11
}
App.Display();
}
}