Jump to content

  • Log In with Google      Sign In   
  • Create Account

#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