I have an odd problem that I believe my relative lack of knowledge of the XNA framework prohibits me from fixing.
Basically I have a Texture2D reference that is set to a new instance of Texture2D. During runtime some of its pixels are set and this all works nicely as its drawn in the gameloop.
The odd thing is, if I set the reference to null, (it will only draw if not null) it as expected does not draw.
Later on, I set the reference to a new Texture2D and it starts drawing it to screen. The issue is it holds all the data of the original Texture2D object.
EDIT
Sorry I wasnt clear before.
What I have is something like this...
private Texture2D WorkingTexture {get; set; }
private void Update()
{
if(some input)
{
this.WorkingTexture = null;
}
if(some other input)
{
this.WorkingTexture = new Texture2D(this.GraphicsDevice, 500, 500, true, SurfaceFormat.Color);
this.WorkingTexture.SetData<Color>(0, new Rectangle((int)vector2.X, (int)vector2.Y, 4, 4), colors, 0, 16);
}
}
private void Draw()
{
if (this.WorkingTexture != null)
{
spritebatch.draw(this.WorkingTexture,.....);
}
}
SECOND EDIT
I have also set a for loop and manually set every pixel of the texture to a color after it is created. this works yet it still shows pixels as the colors i set them previously. This is very odd.
Please disregard this thread. The issue was very embarrassingly my own doing. I had some code that buffered up pixels to be changed and yes... you guessed it I wasn't clearing it and it was doing the work all over again on the new texture instance.
very embarrassed....