Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Copying textures?  (Read 2242 times)

0 Members and 4 Guests are viewing this topic.

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Copying textures?
« 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.
« Last Edit: August 13, 2013, 11:12:43 pm by JunkerKun »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Copying textures?
« Reply #1 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?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Copying textures?
« Reply #2 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.