Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#ActualCornstalks

Posted 06 April 2013 - 11:30 AM

Look at your Draw method. It's returning a copy of a sf::Texture. Copying textures around is expensive. You should return a const reference (sf::RenderTexture::getTexture() returns a const reference to a texture).

In other words, don't copy the texture around. Use references. And be careful, so that you don't hold a reference to the texture if it gets destroyed.

Edit: on second thought, I'm actually not sure this is a slow operation. I know you said it doesn't affect your performance, but I just wanted to add that after thinking about it (and failing to find specific documentation) I'm not sure if it actually copies the texture (that is, it might just reference the same texture in the video card), and if it does copy the texture, it should be pretty quick (if unnecessary) because it should be a graphics card operation.

#1Cornstalks

Posted 06 April 2013 - 10:58 AM

Look at your Draw method. It's returning a copy of a sf::Texture. Copying textures around is expensive. You should return a const reference (sf::RenderTexture::getTexture() returns a const reference to a texture).

 

In other words, don't copy the texture around. Use references. And be careful, so that you don't hold a reference to the texture if it gets destroyed.


PARTNERS