Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Capturing Direct 3D Screen

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?

like image 559
Or Betzalel Avatar asked May 26 '11 16:05

Or Betzalel


1 Answers

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.

like image 135
vcsjones Avatar answered Sep 23 '22 15:09

vcsjones