Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.


Topics - Kov

Pages: [1]
1
Graphics / White Square Problem - Please Help!
« on: August 21, 2014, 07:54:30 am »
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));
}
 

Pages: [1]
anything