SFML community forums
Help => Graphics => Topic started by: chris67 on January 06, 2010, 02:17:59 am
-
Is it safe to use the same sf::Image variable for more then one bitmap?
If I do this for instance:
sf::Image bitmap;
sf::Sprite sprite;
bitmap.LoadFromFile( "bitmap1.bmp" );
sprite.SetImage( bitmap );
App.Draw( sprite );
// and then do this
bitmap.LoadFromFile( "bitmap2.bmp" );
sprite.SetImage( bitmap ); // do I need to do this again?
App.Draw( sprite );
Is this safe or will I get a memory leak somewhere?
-
It's perfectly fine, but the second time you'll have to manually change the subrect of the sprite so that it matches the new size of the image (it is done automatically only the first time).