Sign in to follow this  
Followers 0
Muhammad Haggag

[C++] Overlay sample

7 posts in this topic

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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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?

0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
Hi,

I am trying to find a solution for a similar overlay problem. But, I am unable to open the link you have given in your post. Can you please send this zip to me ? [email="prachi_bhadekar@persistent.co.in%20?I"]I[/email] would appreciate it.Thanks a ton!


[quote name='Muhammad Haggag' timestamp='1132555219' post='359319']
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 [url="http://nexe.gamedev.net/files/Overlay-2005-11-21.zip"]unmanaged overlaying sample[/url]. 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:[b]Overlay.cpp[/b]: Window creation (auto-generated, nothing interesting) and the main loop (important).[b]overlay_renderer.h[/b], [b]overlay_renderer.cpp[/b]: 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:dwAlignBoundarySrcdwAlignSizeSrcdwAlignBoundaryDestdwAlignSizeDestdwAlignStrideAlign dwMinOverlayStretch dwMaxOverlayStretchThe 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.
[/quote]
0

Share this post


Link to post
Share on other sites
I know this is old, but does anyone still have the sample for this? The main link does not work anymore.
0

Share this post


Link to post
Share on other sites
[url="http://web.archive.org/web/20070205214248/http://nexe.gamedev.net/files/Overlay-2005-11-21.zip"]http://web.archive.o...-2005-11-21.zip[/url]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0