Multiple Texture2D.GetData to Color[] and Texture2D.SetData iterations causes corrupted buffer? #8272
Closed
wouldBeNerd
started this conversation in
Graphics
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I renamed this discussion because the original title was not very reflective of the issue.
ISSUE
I was overwriting existing Texture2D variable multiple times with
new Texture2D(GraphicsDevice, width, height)
SOLUTION
Doing this does not guarantee you a blank Texture, I don't know if it is possible to write it in a way that it is guaranteed (suggestions welcome).
To solve it i ended up iterating all the colors of the Texture and setting them to transparent .
This is slow and not recommended during runtime (might be useful during load time though)
ORIGINAL STORY BELOW
Hi! I am building a marching square tileset from a single row of vertical walls and ceiling tile.
The tilerow on the left becomes the tilesets in the middle and can then be used for map building.
Pretty cool I thought, but something is getting corrupted, i had to run multiple times to get it to be this clean.
More often then not, it comes out corrupted in ways similar to the picture below. I am using multiple iterations of Texture2D.GetData to Color[] and Texture2D.SetData during Load-time to generate the marching square textures. Anyone know what the problem might be? I am writing rows of pixels from the original Texture2D to a separate Texture2D in multiple iterations. Is it possible to cause some kind of overflow?
Beta Was this translation helpful? Give feedback.
All reactions