SFML community forums

Help => Graphics => Topic started by: Kaphonaits on May 02, 2013, 10:46:05 am

Title: How are sf::Textures saved?
Post by: Kaphonaits 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
Title: Re: How are sf::Textures saved?
Post by: Laurent 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?
Title: Re: How are sf::Textures saved?
Post by: Kaphonaits on May 07, 2013, 07:49:52 am
Yes it does. Thanks!