Ok . Here it is all the code I think it's needed
template <typename Resource, typename Identifier>
void ResourceHolder<Resource, Identifier>::load(Identifier id, const std::string &filename)
{
std::unique_ptr<Resource> resource(new Resource());
if(!resource->loadFromFile(filename)) //it breaks inside the loadFromFile function
{
throw std::runtime_error("ResourceHolder::load couldn't load " + filename);
}
auto inserted = mResourceMap.insert(std::make_pair(id, std::move(resource)));
assert(inserted.second);
}
void World::loadTextures()
{
std::cout << "world::loadtextures\n";
mTextures.load(Textures::Eagle, "Media/Gfx/Eagle.png"); //the above function is called here
std::cout << "eagle done\n";
mTextures.load(Textures::Raptor, "Media/Gfx/Raptor.png");
std::cout << "raptor done\n";
mTextures.load(Textures::Desert, "Media/Gfx/Desert.png");
std::cout << "desert done\n";
}
I made sure the files are there (even if they weren't it shouldn't give a bus error.
The World constructor
World::World(sf::RenderWindow& window)
: mWindow(window)
, mWorldView(window.getDefaultView())
, mTextures() //constructor of mTextures here !!!
, mSceneGraph()
, mSceneLayers()
, mWorldBounds(0.f, 0.f, mWorldView.getSize().x, 2000.f)
, mSpawnPosition(mWorldView.getSize().x / 2.f, mWorldBounds.height - mWorldView.getSize().y / 2.f)
, mScrollSpeed(-50.f)
, mPlayerAircraft(nullptr)
{
std::cout << "constr world::world\n";
loadTextures();
buildScene();
mWorldView.setCenter(mSpawnPosition);
std::cout << "exit world::world\n";
}
Also, the code compiles under g++ with c++0x standard.