Overlay is a hardware function of a video card that makes it possible to overlay an image on the main screen (primary surface) without copying the video memory. Overlay is performed in video card digital-to-analog converters (RAMDAC) in the process of creating video signals sent to the monitor. RAMDAC scans the primary surfaces line by line during the process and switches to an overlay image when it comes to it.
Necessary
A set of special effects from libraries
Instructions
Step 1
To enable Overlay, it is necessary to consider writing a program that displays some special effects on the surface of the desktop, or in places of arbitrary colors (if we consider the drawing mode on the desktop as the main mode).
Step 2
Choose a special effect. Regarding the choice of special effects, you should not be especially difficult - they can simply be borrowed from examples to the FastLIB libraries, for example, the algorithms for drawing a fireball. After that, you need to add a simple system of particles to the effect, and name the result as it will be convenient. Initialize DirectDraw. Only primary surfaces make sense to initialize.
Step 3
Check the ability to display the overlay and create it. To do this, use the GetOverlayCaps function. There is nothing complicated and interesting in GetOverlayCaps - it is a transfer from DDCaps of each bit or value associated with overlays into a more compact structure - TOverlayCaps. Next, you should correct the size of the overlay so that they correspond to the parameters obtained during the use of the function. In reality, the probability of successful execution of such code is extremely insignificant, so you should not particularly focus on it - in particular, its size should not be limited in order to avoid slow work, it is not necessary to check the size in bytes for the possibility of penetrating the contents of the video memory, and so on.
Step 4
In general, it is worth checking more to get a report, since the very process of creating an overlay is done by a brute-force method. The point is that no functions like EnumOverlayFormats exist and have not been created, so the user should check any imaginable format and hope to be lucky. There is, however, a function IDirectDraw7GetFourCCCodes, which is designed to determine the non-RGB format code (FourCC), but it includes not only the necessary YUV, but also the compressed texture format, and others. To use the entire list and define each format as YUV or non-YUV seems irrational.
Step 5
Remove the image from the desktop, if present, and assign DCK colors to it. Enable DCK color overlay. The overlay will be turned on and ready to go. The visual effects of its use can be assessed after minimizing all working windows.