Hi,
I am having a lot of trouble with this and don't understand why I am getting the white square problem.
I have a class that handles all my assets (including textures) called CAssetManager and I use it by calling a function called LoadTexture(int id, std::string file) which loads the texture into a std::map<int, sf::Texture>. Then when I create a sprite, I set the texture of the sprite using a function called GetTexture(int id). This gives me a white square at the textures size.
Please Help!!
Here is my (reduced) CAssetManager.h code:
public:
void LoadTexture(int id, std::string file);
sf::Texture GetTexture(int id);
private:
std::map<int, sf::Texture> textureMap;
Here is my (reduced) CAssetManager.cpp code:
void CAssetManager::LoadTexture(int id, std::string file)
{
textureMap[id].loadFromFile(file);
}
sf::Texture CAssetManager::GetTexture(int id)
{
return textureMap[id];
}
Here is my (reduced) CMain.h code:
public:
CMain();
private:
sf::Sprite sprite;
CAssetManager asset;
And finally, here is my (reduced) CMain.cpp code:
CMain::CMain()
{
asset.LoadTexture(0, "test.png");
sprite.setTexture(asset.GetTexture(0));
}