SFML community forums

Help => Graphics => Topic started by: JunkerKun on August 13, 2013, 11:10:47 pm

Title: Copying textures?
Post by: JunkerKun on August 13, 2013, 11:10:47 pm
Hi again.

How do I properly copy one texture to another?
More exact, how do I copy RenderTexture's texture into an ordinary texture? Right now I have something like this:
        sf::RenderTexture renderTexture;
        renderTexture.create(characterSize.x,characterSize.y);
        renderTexture.clear(sf::Color::Transparent);
        sf::Texture spriteTexture;
        sf::Sprite sprite;
        spriteTexture.loadFromFile("Data/Graphics/BodyBack.png");
        sprite.setTexture(spriteTexture);
        renderTexture.draw(sprite);
        renderTexture.display();
        tex=renderTexture.getTexture();
 

where "tex" is a reference to a texture I want to copy to.
Title: Re: Copying textures?
Post by: Nexus on August 13, 2013, 11:25:43 pm
sf::Texture has value semantics, i.e. you can use copy constructor and assignment operator as in your code.

So tex = renderTexture.getTexture(); is correct, is there a problem with it?
Title: Re: Copying textures?
Post by: JunkerKun on August 14, 2013, 01:13:16 am
sf::Texture has value semantics, i.e. you can use copy constructor and assignment operator as in your code.

So tex = renderTexture.getTexture(); is correct, is there a problem with it?

No, I was just wondering if it is the right way to do so.
Thanks.