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.


Messages - Kov

Pages: [1]
1
Graphics / Re: White Square Problem - Please Help!
« on: August 21, 2014, 08:13:39 am »
Alright sweet thanks a ton! I shall buy one of those books and read it. I think I may have learnt c++ off one of those "Bad" books. :P

2
Graphics / Re: White Square Problem - Please Help!
« on: August 21, 2014, 08:03:14 am »
Yea I don't use references or pointers because I never could get my head around them when I was learning c++. Do you know any good sources or books that could explain them to me?

Thanks for the reply.

EDIT: I have found the Website on Thor's Resource Manager and will give it a read.

3
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