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

Author Topic: How are sf::Textures saved?  (Read 1581 times)

0 Members and 1 Guest are viewing this topic.

Kaphonaits

  • Newbie
  • *
  • Posts: 21
    • View Profile
How are sf::Textures saved?
« on: May 02, 2013, 10:46:05 am »
To elaborate/be more specific, are sf::Textures copied into the sf::Sprite or does the sf::Texture need to always be reference-able by the variable?

Explanations? :D
The keyboard is mightier than the sword.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How are sf::Textures saved?
« Reply #1 on: May 02, 2013, 10:47:38 am »
Quote from: Sprite.cpp
void Sprite::setTexture(const Texture& texture, bool resetRect)
{
    ...

    m_texture = &texture;
}

Quote from: Sprite tutorial
When you set the texture of a sprite, all it does internally is to keep a pointer to the texture instance. Therefore, if the texture is destroyed or moves elsewhere in memory, the sprite ends up with an invalid texture pointer.

Does it answer your question?
Laurent Gomila - SFML developer

Kaphonaits

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: How are sf::Textures saved?
« Reply #2 on: May 07, 2013, 07:49:52 am »
Yes it does. Thanks!
The keyboard is mightier than the sword.

 

anything