SFML community forums

Help => Graphics => Topic started by: stevend on January 19, 2010, 07:34:14 pm

Title: reference of an image? just a quick question
Post by: stevend on January 19, 2010, 07:34:14 pm
ok so i have made my own resource manager

and there is a function to return a pointer to an image?

its defined like this

sf::Image * GetImage(filepath);

when i try to do this:

mysprite.setimage(GetImage(filepath));

i get this error:

Error   1   error C2664: 'sf::Sprite::SetImage' : cannot convert parameter 1 from 'sf::Image *' to 'const sf::Image &'   

how would i pass this back or what would i cast this as to make it work? thank you!
Title: reference of an image? just a quick question
Post by: Laurent on January 19, 2010, 07:41:42 pm
You have a pointer, so you need to dereference it:
Code: [Select]
mysprite.setimage(*GetImage(filepath));
But you should first check if the returned pointer is not null. And if it can never be null, then just return a reference.
Title: reference of an image? just a quick question
Post by: stevend on January 19, 2010, 07:48:06 pm
thanks, that was easy enough, programming in the morning can make me go nuts haha.


now my program crashes when i exit.... ill have to do some more debugging...