This is a little image manager I wrote, but I don't know what I'm doing wrong. Shouldn't this work? (am using SFML 2.0 with Visual Studio 2010 Ultimate)
class zImage : public Image{
public:
string Name;
string Category;
void Load(string GetCategory, string getName){
Name = getName;
Category = GetCategory;
LoadFromFile ( "Graphics/" + Category + "/" + Name + ".png" );
SetSmooth ( false );
}
};
class ImageManager{
std::vector<zImage> ImageList;
public:
zImage &GetImage(string GetCategory, string GetName){
for ( long index = 0; index < (long)ImageList.size(); index++ ) {
if (ImageList[index].Category == GetCategory){
if (ImageList[index].Name == GetName){
return ImageList[index];
}
}
}
// Image was not found, so create it and return it
zImage tempImage;
tempImage.Load(GetCategory, GetName);
ImageList.push_back(tempImage);
return tempImage;
}
}Images;
Example usage:
Sword.SetImage(Images.GetImage("Swords", "Iron"));
I get an unhandled exception and it brings me to this code in MutexImpl.cpp
////////////////////////////////////////////////////////////
void MutexImpl::Lock()
{
EnterCriticalSection(&myMutex);
}