In my application I need to take a screenshot of a DirectX11 game. This is the code I have been using to get bitmaps of the screen.
Bitmap bmpScreenshot = new Bitmap(length, length, PixelFormat.Format32bppArgb);
Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot);
gfxScreenshot.CopyFromScreen(0, 0, 0, 0, new Size(1920, 1080), CopyPixelOperation.SourceCopy);
This code works perfectly fine if vsync is enabled in the game but when turned of, sometimes the screenshots become glitchy and buggy showing areas of the map being rendered while still in the menu. Enabling vsync takes a pretty big toll on performance and Id like to find a way to get good screenshots with it turned off. What can I change about my code or add so that my screenshots still look like whats being displayed on the screen with vsync turned off. The game is Rainbow Six Siege and for context here is how the screenshot should look: Normal Screenshot. And this is how it comes out sometimes when vsync is disabled: Glitched Screenshot.