I implemented a basic screenshotter using RenderTarget2D and Texture.SaveAsPng. The functionality works fine, but the File I/O hangs the game while it completes (of course). I thought “I’ll just put it on a new thread”, but I’m getting the “Operation not called on UI thread” exception.
I started googling around and am a bit out of my depth here - I can probably count on one hand the number of times I’ve done anything multi-threaded. From what I read, Texture data is problematic across threads and especially in DesktopGL projects? Is this correct?
Has anyone done something similar or have an alternative approach? I’m a bit lost here
EDIT: I’m also getting a weird behavior on my DX build - anytime the resolution is set anywhere near 1280x720 (I’ve tried various combinations of numbers, and non-standard resolutions), the bottom 1/5 or so of my render is cut off. It appears black in the image, but looking at the file, it’s actually transparent. If I increase the resolution to 1440x900 or decrease it, the render works correctly.
EDIT2: I found the problem with the screenshot cutting off, I was using the wrong SpriteBatch.Begin() override - I needed to use SamplerState.PointClamp. I feel sheepish lol. However, I’m still stuck on my original problem.