Hi,
i having a weird situation that i do not understand, maybe someone could explain me what happens and if there is a way to prevent this.
I have a level, built from a tile map, that i render into a RenderTexture (the whole map at once). Although drawing only the visible portion of the tile map would be faster, i need this to be able to modify the level by for example adding blood splatter onto the tiles.
From that render texture, i build a sprite, and that i do render.
Now everything works fine, until i do load any other texture after setting up the RenderTexture object. Once i load any texture object, the RenderTexture seems to get replaced with that texture.
So in code speaking (not the actual code, just to make clear what i am talking about):
RenderTexture t;
Sprite s;
Texture otherTex;
Sprite otherSprite;
void init() {
otherTex.LoadFromFile("sprite.png");
otherSprite.SetTexture(otherTex);
RenderTexture t;
t.Create(800, 600);
DrawMap(t);
t.Display();
s.SetTexture(t.GetTexture());
}
void draw() {
window.Clear();
window.Draw(s);
}
does work, while...:
void init() {
RenderTexture t;
t.Create(800, 600);
DrawMap(t);
t.Display();
s.SetTexture(t.GetTexture());
otherTex.LoadFromFile("sprite.png");
otherSprite.SetTexture(otherTex);
}
void draw() {
window.Clear();
window.Draw(s);
}
...does draw a large scaled image of sprite.png
Why is this happening?