Home » Community » Forums » DirectX and XNA » [C++] Overlay sample
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 [C++] Overlay sample
Post New Topic  Post Reply 
A lot of people seem interested in knowing how to render content over full-screen applications, like XFire and Co, judging by the number of posts about it. Here’s an unmanaged overlaying sample. Visual Studio 2003 and 2005 solutions are included.

The sample uses DirectDraw overlays to render a black 256x64 box to the top-left of the screen, with some text in it. I would’ve shown you a screenshot, but I can’t, due to the way overlays work. Overlays are displayed as the device is painting the monitor from the primary surface. If it’s painting a location where an overlay exists, it paints the monitor with its color instead of the primary surface. Consequently, you can’t capture that in an image.

Back to the sample. The files of interest are:
Overlay.cpp: Window creation (auto-generated, nothing interesting) and the main loop (important).
overlay_renderer.h, overlay_renderer.cpp: The core of the sample. The code is fairly self-explanatory, though.

One important thing to keep in mind is that overlay support comes with a set of limitations. The following limitations are not checked or accounted for in the sample:
dwAlignBoundarySrc
dwAlignSizeSrc
dwAlignBoundaryDest
dwAlignSizeDest
dwAlignStrideAlign
dwMinOverlayStretch
dwMaxOverlayStretch

The limitations are hardware-dependent. For example, my X300 doesn’t impose any alignment restrictions for the source or destination overlay rectangles. In a product, however, you’d want to make sure you check for these and abide by them. Use CapsViewer to find out the limitations of your hardware quickly. I don’t know if the October SDK caps database includes DirectDraw caps or not, but consider checking it out.

The limitations (and overlays in general) are documented under “DirectDraw->DirectDraw Essentials->Surfaces->Overlay Surfaces” in the DX7 documentation. It’s available at icarusIndie.

I might write a managed port, if someone’s interested. All feedback’s welcome.

 User Rating: 1823   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Good job coder!

 User Rating: 1737   |  Rate This User  Send Private MessageView ProfileView JournalView GD Showcase Entries Report this Post to a Moderator | Link

You could always inject your own drawing code into the program (at runtime). However it would be a lot of work and you'd have to redo it for every game and probably whenever the binary changes.

 User Rating: 1109   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Wasn't there a sample in one of the older DXSDK's that showed how to do this (mosquito)?


Too bad D3D won't allow you to use the hardware overlay surface as a render target or as the front buffer in a swap chain.

What would be the best way to render 3D over the desktop? I'm guessing you'd have to render to a surface that you could lock, then copy the bits from surface to a locked DDraw overlay surface using the CPU? Ick!

I think you could actually do this all in hdwe on DX7 since the render target was a DDraw surface?



 User Rating: 1220   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Quote:
Original post by don
Wasn't there a sample in one of the older DXSDK's that showed how to do this (mosquito)?

Yes, I've used that sample's documentation as a reference long ago - I couldn't find the sample itself anymore (and I didn't want to download the whole SDK).

Quote:
What would be the best way to render 3D over the desktop? I'm guessing you'd have to render to a surface that you could lock, then copy the bits from surface to a locked DDraw overlay surface using the CPU? Ick!

That's how I've done it a while ago - I rendered using D3D8, locked the target surface, copied the bits to a ddraw surface and presented to only the bits that had the desktop background color.

Quote:
I think you could actually do this all in hdwe on DX7 since the render target was a DDraw surface?

I seem to recall I looked into this a bit, and it seemed possible, but I didn't bother. I went down the ActiveDesktop + ActiveX control route.


 User Rating: 1823   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: