### SFML Problem

I am following the SFML tutorial on http://www.sfml-dev.org/tutorials/1.6/graphics-sprite.php and it compiles perfectly, but the sprite has a grey outline on the top and left sides. Here is my code:

 1234567891011121314151617181920212223242526272829 #include int main() { sf::RenderWindow App(sf::VideoMode(800,600,32), "Render Window"); while(App.IsOpened()) { sf::Event event; while(App.GetEvent(event)) { if(event.Type==sf::Event::Closed) { App.Close(); } } sf::Image ManImage; ManImage.LoadFromFile("man.jpg"); sf::Sprite Man; Man.SetImage(ManImage); Man.SetPosition(200.f,100.f); Man.SetColor(sf::Color(255,255,255,255)); App.Clear(sf::Color(255,255,255)); App.Draw(Man); App.Display(); } return(0); } 

All help is greatly appreciated.
Maybe the alpha channel in SetColor? Also you might want to use SFML2 instead, 1.6 I believe is already deprecated.
Changing and removing the alpha value did not help, do you think it is the version that is causing the problem?
Honestly, I have no idea I'm still pretty new to SFML myself. Does it happen with all images or just the one?
Edit: Your doing a lot in the while loop including loading the image, try moving that out of the loop.
Last edited on
Add this line somewhere and see if the problem persists -> ManImage.SetSmooth(false);

Also, loading the image before entering the main loop is a good idea (not related to the problem though).
Last edited on
I used the SetSmooth() function and it works perfectly, thank you.

m4ster r0shi wrote:
Also, loading the image before entering the main loop is a good idea (not related to the problem though).

where should i put it, before the first while, or in a separate function, or global?
Script Coder wrote:
where should i put it

Anywhere, as long as it's before the main loop. You don't want to
load it every time you want to draw it. You only need to load it once.

Script Coder wrote:
in a separate function

Nah, no need to complicate things too much.
Last edited on
 1.6 I believe is already deprecated

According to their site, 1.6 is the current version is 2.0 is the "future version".

Actually take Lines 7, 15, 16, 18, 19, 20 and 21 and put them outside of your main running loop. Make sure to only run declarations and the like once for each object\item.
 According to their site, 1.6 is the current version is 2.0 is the "future version".

1.6 is the current official release, but the release candidate for SFML 2.0 is already released, and an official release is right around the corner. Even the maker of SFML says that 1.6 is deprecated.

Here is a quote from the SFML forum:

 SFML 1.6 is already deprecated, and although there's no official release of SFML 2.0 yet there is a RC which is already 99.999% of what the final release will be.

Source: http://en.sfml-dev.org/forums/index.php?topic=8210.0 , the second last post.
Thanks for all the replies, I think I'll move to SFML 2.0 when i am done learning the basic interface for SFML 1.6 (just the graphics part).
@ Script Coder: Do yourself a HUGE favor and don't do that. Just jump right into SFML 2.0. I am used to 1.6, I'd confidently say that I know it well but now that I am moving to 2.0 things have changed quite a bit. Both major things like how you are meant to handle events and minor things like the capitalization in the function names. It's getting really annoying having to keep going back to the tutorial for something that I can tell you off the top of my head how to do in 1.6.
Okay, Thanks Computerggek01, one problem, the 2.0 tutorial is not done yet, last i saw it only was at window package section. Or is there another tutorial i don't know about?
 the 2.0 tutorial is not done yet

2.0 isn't that different from 1.6. There's a changelog posted, but I think the main thing that'll get you is sf::Input is removed, and replaced by sf::Mouse, sf::Keyboard, and sf::Joystick I believe.

Not a huge change, but if you're using sf::Input, you'll just need to replace it with the appropriate object.

Other than that, they have pretty good documentation there.
Topic archived. No new replies allowed.