I'm manipulating a Texture2D with Texture2D.Setdata and change its color.
But i want to reset the Texture2D after a Time again, currently im having the whole Texture Datas in Memory, but now i have OutOfMemoryExceptions in my App.
I Tried this:
Color[] bla = new Color[thetexture.Width * thetexture.Height];
this.Content.Load<Texture2D>(".\\textures\\mytexture").GetData(bla);
thetexture.SetData(bla);
But it doesn't change anything, the texture just stays colored.
How can I reset the texture, so that it looks like freshly loaded, but with a small Memoryuse?
ContentManager
caches objects. Your call to Load
is returning what is presumably the same object as your thetexture
(the one you already modified).
You need to load a separate instance of your texture with the original data. You need a separate ContentManager
for that. Possibly one that has been customised to never cache objects.
Alternately, create a new Texture2D
object and copy the original data into that before modifying it, leaving the original untouched.