Hello all,
I just started using SFML and I'd like to make an image manager.
I used a vector to do so and everytime I try loading an image I get a return error saying it could not load image.
I'm 100% sure of my paths
![Wink ;)](https://www.sfml-dev.org/forums/Smileys/default/wink.gif)
(changed them of folder etc..)
I tried PNG, BMP and JPG with a simple image made in paint, same result.
Did I oversee something with my pointers?
Could it come from the fact I use a struct ?
struct SFML_Manager_Image
{
sf::Image Img;
sf::Sprite Sprite;
std::string FileName;
};
SFML_Manager_Errors SFML_Manager::LoadImageTest(const std::string &ImgFileName, unsigned int &ImgID)
{
SFML_Manager_Image *NewImageBuffer;
bool AlreadyLoaded = false, FuncResponse;
unsigned int LoadedIndex;
unsigned int iImgIndex;
// Create a new buffer and instance
NewImageBuffer = new SFML_Manager_Image;
// Check if the img file is already loaded
for(iImgIndex=0;iImgIndex > (SFML_Manager::ImageList.size() - 1);iImgIndex++)
{
if (SFML_Manager::ImageList[iImgIndex].FileName == ImgFileName)
{
AlreadyLoaded = true;
LoadedIndex = iImgIndex;
}
}
// Load image file?
if (!AlreadyLoaded)
{
FuncResponse = NewImageBuffer->Img.LoadFromFile(ImgFileName);
if (!FuncResponse)
{
delete NewImageBuffer;
return Failure;
}
// Set the image on a sprite
NewImageBuffer->Sprite.SetImage(NewImageBuffer->Img);
}
else
{
// Set the image on a sprite
NewImageBuffer->Sprite.SetImage(SFML_Manager::ImageList[LoadedIndex].Img);
}
// Save File name
NewImageBuffer->FileName = ImgFileName;
// Return the sound Index
ImgID = SFML_Manager::ImageList.size() - 1;
return Success;
}
[/code]