C# Capturing Direct 3D Screen

Or Betzalel picture Or Betzalel · May 26, 2011 · Viewed 8.4k times · Source

I have been fooling around with screen capture for awhile now and I managed to capture the entire screen, certain areas on the screen etc...

But when I go into a game and try to capture the screen, it completely ignores the game and instead, captures the desktop (or whatever is behind the game window). Another interesting fact is that the same thing happens with the PrtScn button.

Any ideas on how to capture a game's screen?

Answer

vcsjones picture vcsjones · May 26, 2011

The screen capturing technique you are using works well for capturing things that aren't hardware accelerated. I suspect you'd have the same problem trying to capture a movie frame in Windows Media Player.

The solution is the do a screen capture from the hardware itself using DirectX. This article explains how to do that with some code and a managed wrapper around DirectX called SlimDX.

EDIT If Slim DX doesn't work for you, then you'd just have to find another managed wrapper around Direct X. I don't think you are going to be able to do the screen capture without working at the hardware level, and DirectX is the means of doing that on the Windows platform.