Using DirectDraw to Capture the Screen - Alternative via Direct3D

I have a function which captures part of the screen and places it into a memory DC using DirectDraw7. I have very specific reasons why I need to use DirectDraw versus GDI to capture the screen and explaining them is irrelevant.

The DirectDraw7 algorithm is very straightforward and works great:

DirectDrawCreateEx(NULL,...,&lpDDrawObject7)

[...]

surfDescPrimary.ddsCaps.dwCaps      = DDSCAPS_PRIMARYSURFACE
lpDDrawObject7->CreateSurface( &surfDescPrimary, &lpSurfacePrimary, NULL );

[...]

surfDescBBuffer.ddsCaps.dwCaps      = DDSCAPS_OFFSCREENPLAIN;
lpDDrawObject7->CreateSurface( &surfDescBBuffer, &lpSurfaceBackBuffer, NULL );

lpSurfaceBackBuffer->BltFast(0,0,lpSurfacePrimary,prCopyScreenRect,DDBLTFAST_NOCOLORKEY);
hr = lpSurfaceBackBuffer->GetDC(&hBSurfDC);
...


The problem is that I need to support multiple monitors and the latest OSes (from Win2k to Win7). I tried to use the DirectDrawEnumerateEx api to query the monitor's GUID but this function returns DDERR_UNSUPPORTED (as well as DirectDrawEnumerate).

I know that DirectDraw has been deprecated and transferred over to Direct3D9. So I assume that on Vista (for instance), DirectDrawCreateEx,CreateSurface and BltFast are supported, but not DirectDrawEnumerateEx.

This only gives me half of a solution to capture the screen efficiently.

I am looking for alternative to either:

A. Query the GUIDs of monitors attached to the desktop so that I can use them in DirectDrawCreateEx.

B. A similar algorithm through D3D9 to capture the screen efficiently (avoiding the GetFrontBufferData API which is slow by design).


Any expert suggestion?




PBERGEOTAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jose ParrotGraphics ExpertCommented:
The aim of DX and other "highlevel" graphics APIs is to turn the applications free of the device dependency. The more you need such low level capture the more your code is device dependent.
In the old times we need to scan rows and columns of the keyboards with our code to discover which key was pressed. Nowadays systems are more and more device independent, say, there are programming layers: the device firmware communicates with the device driver which communicates with the BIOS which communicates with the operating system which communicates with the API which communicates with the application. So, making the application to communicate directly with the hardware is VERY difficult, although not impossible, but your program needs to know all about all the devices. And, as soon you terminate your code, a new device will run not properly until you write thr right code to it.
Jose Parrot
0
PBERGEOTAuthor Commented:
I found out that specifying a NULL GUID to DirectDrawCreateEx returns access to the full desktop (and not just a monitor). From there I use absolute coordinates to capture the desired parts of the screen.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Game Programming

From novice to tech pro — start learning today.