SFML community forums

Help => General => Topic started by: Mars_999 on March 01, 2012, 03:00:52 am

Title: SF::Context and threaded texture loading
Post by: Mars_999 on March 01, 2012, 03:00:52 am
I get an error when running the .exe outside of MSVC++ saying "Failed to share OpenGL context"....

When inside MSVC++ I don't get an error or issue. The window stops and only shows white.

So I am not sure what I am doing wrong but thought I seen an example all I had to do was just throw in a Sf::Context to make the multithread image loader work... Guess not.

SO what am I doing wrong here.

Code: [Select]


void NX::App::LoadResources(void)
{
static sf::Thread thread(&NX::ResourceManager::Load, NX::ResourceManager::Get());
thread.Launch();
}

void NX::ResourceManager::Load(void)
{
LoadSplashScreen();
LoadDefault();
LoadMaps();
}
void NX::ResourceManager::LoadSplashScreen(void)
{
//sf::Context context;
NX::FileSystem::Get()->GetDirComponents(NX::FileSystem::Get()->GetPath() + PATH_SPLASHSCREENS, splashScreenFiles);
for(unsigned int i = 0; i < splashScreenFiles.size(); ++i)
{
try
{
splashScreenFiles[i].erase(0, splashScreenFiles[i].find_last_of("//") + 1);
if(!Find(splashScreenFiles[i]))
{
NX::Resource* p = new NX::ResourceTexture(splashScreenFiles[i]);
p->Load(NX::FileSystem::Get()->GetPath() + PATH_SPLASHSCREENS);
Insert(p);
}
else
{
THROW_EXCEPTION(0, std::string("Already loaded: ") + splashScreenFiles[i]);
}
}
catch(NX::Exception& e)
{
NX::ErrorManager::Get()->Log(e);
}
}
glFlush();
splashScreensReady = true;
}

Title: SF::Context and threaded texture loading
Post by: Mars_999 on March 03, 2012, 09:54:59 pm
Ok anyone have a tutorial on how to do this correctly then? Or willing to share some code?

Thanks!!!!