Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Graphics
»
reference of an image? just a quick question
Print
Pages: [
1
]
Author
Topic: reference of an image? just a quick question (Read 2024 times)
0 Members and 1 Guest are viewing this topic.
stevend
Newbie
Posts: 20
reference of an image? just a quick question
«
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!
Logged
Laurent
Administrator
Hero Member
Posts: 32498
reference of an image? just a quick question
«
Reply #1 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.
Logged
Laurent Gomila - SFML developer
stevend
Newbie
Posts: 20
reference of an image? just a quick question
«
Reply #2 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...
Logged
Print
Pages: [
1
]
SFML community forums
»
Help
»
Graphics
»
reference of an image? just a quick question