SFML community forums
General => Feature requests => Topic started by: zeocyte on December 23, 2011, 09:19:44 am
-
This suggestion is just for convenience. Perhaps we could an overloaded version of sf::RenderTexture's GetTexture() which returns a copy of sf::RenderTexture's texture.
Please note that we will not be wasting resources when done in this way for we can "recycle" an sf::RenderTexture (in other words, use it to create another texture). But then we will have to modify sf::RenderTexture::Create() to free the previous resources used (I have looked into the code).
Hoping for Laurent's very kind consideration. :wink:
-
As long as sf::Texture is copyable, you can create copies even if a reference is returned.
sf::Texture copy = renderTexture.GetTexture();
Or did I totally misunderstand your request?
-
I had recently looked into the = operator of sf::Texture and it "returns" a reference and not a copy. In my suggestion, it implies that we can use just one instance of sf::RenderTexture to create many instances of sf::Texture. We cannot do this however, if GetTexture() returns only references.
-
I had recently looked into the = operator of sf::Texture and it "returns" a reference and not a copy
Every operator = returns a reference, it's the standard prototype. It doesn't mean that they don't do their job correctly. If you think about it, it would make no sense if it returned a copy.
Textures are copyable, so you can... copy them, it works. Stop looking at the code and making false assumptions about it, just trust me (or read more C++ books if you don't) ;)