121
System / Using threads to load stuff
« on: September 08, 2011, 04:52:05 pm »
Passing it to the function as a reference didnt work, but using a global variable did
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
bool threadRunning = false;
void loadFiles()
{
threadRunning = true
...
threadRunning = false
}
sf::Thread loadingThread( &loadFiles);
loadingThread.Launch();
while( threadRunning)
{
Animate and draw loading screen
}
void loadFiles()
{
...
}
sf::Thread loadingThread( &loadFiles);
loadingThread.Launch();
while(loadingThread.isRunning)
{
Animate and draw loading screen
}
TitleText.SetOrigin(TitleText.GetRect().Width / 2, TitleText.GetRect().Height / 2);
NewGameText.SetOrigin(NewGameText.GetRect().Width / 2, NewGameText.GetRect().Height / 2);
OptionsText.SetOrigin(OptionsText.GetRect().Width / 2, OptionsText.GetRect().Height / 2);
QuitText.SetOrigin(QuitText.GetRect().Width / 2, QuitText.GetRect().Height / 2);
std::cout << "draw sfml" << loop << std::endl;
Game::DrawSFML();
std::cout << "display" << loop << std::endl;
// Display window contents on screen
App.Display();
std::cout << "end" << loop << std::endl;
loop++;
==6759== Conditional jump or move depends on uninitialised value(s)
==6759== at 0x4049DFA: sf::Renderer::SetShader(sf::Shader const*) (in /usr/local/lib/libsfml-graphics.so.2.0)
==6759== by 0x4395FFFF: ???
==6759==
==6759== Conditional jump or move depends on uninitialised value(s)
==6759== at 0x4049C28: sf::Renderer::SetBlendMode(sf::Blend::Mode) (in /usr/local/lib/libsfml-graphics.so.2.0)
==6759== by 0x4395FFFF: ???
==6759==
==6759== Conditional jump or move depends on uninitialised value(s)
==6759== at 0x4049D48: sf::Renderer::SetTexture(sf::Texture const*) (in /usr/local/lib/libsfml-graphics.so.2.0)
==6759== by 0x404F191: sf::Sprite::Render(sf::RenderTarget&, sf::Renderer&) const (in /usr/local/lib/libsfml-graphics.so.2.0)
==6759== by 0x4033F57: sf::Drawable::Draw(sf::RenderTarget&, sf::Renderer&) const (in /usr/local/lib/libsfml-graphics.so.2.0)
==6759== by 0x4395FFFF: ???
Game::isOpenGLSetup = Game::setupOpenGL();
App.SetFramerateLimit(GlobalSettings::globalSettings.getFrameRateLimit() );
App.ShowMouseCursor(false);
sf::VideoMode desktopVM = sf::VideoMode::GetDesktopMode();
App.SetPosition( (desktopVM.Width/2.0) - (App.GetWidth()/2.0) , (desktopVM.Height/2.0) - (App.GetHeight()/2.0) );
smView = sf::Vector2i(800,600 );
winView = sf::Vector2i(GlobalSettings::globalSettings.getWinWidth() , GlobalSettings::globalSettings.getWinHeight() );
App.Show(true);