I have a DBObject that stores media (an sf::Sprite) and mediaTexture (an sf::Texture). This is my DBObject::loadMedia() function:
void DBObject::loadMedia() {
myStream mediaStream(mediaPath);
mediaTexture.loadFromStream(mediaStream);
media.setTexture(mediaTexture);
mediaInit = true;
}
These DBObjects are stored in a std::vector.
When I try to draw the sprite to the display, it is completely white, and apparently this is from the texture going out of scope. But I define the texture in the DBObject, so it should have a lifetime of the object... right?
However, when I make a NEW sprite in my main() function, and do newSprite.setTexture(DBObj.mediaTexture), it is displayed fine, so the texture itself is loading fine, but something is happening to the sprite.