19,518
社区成员




Overlay surfaces are assumed to be on top of all other screen components, but when you display multiple overlay surfaces, you need some way to visually organize them. DirectDraw supports overlay z-ordering to manage the order in which overlays clip each other. Z-order values represent conceptual distances from the primary surface toward the viewer. They range from 0, which is just on top of the primary surface, to 4 billion, which is as close to the viewer as possible, and no two overlays can share the same z-order. You set z-order values by calling the IDirectDrawSurface5::UpdateOverlayZOrder method.
Destination color keys are affected only by the bits on the primary surface, not by overlays occluded by other overlays. Source color keys work on an overlay whether or not a z-order was specified for the overlay.
Overlays without a specified z-order are assumed to have a z-order of 0. Overlays that do not have a specified z-order behave in unpredictable ways when overlaying the same area on the primary surface.
A DirectDraw object does not track the z-orders of overlays displayed by other applications.
Note You can ensure proper clipping of multiple overlay surfaces by calling UpdateOverlayZOrder in response to WM_KILLFOCUS messages. When you receive this message, set your overlay surface to the rearmost z-order position by calling the UpdateOverlayZOrder method with the dwFlags parameter set to DDOVERZ_SENDTOBACK.
Hello
I have a small DirectX 7 application that has to "block" all available
within overlay surfaces. So I use DD7, call GetCaps, check the
DDCAPS::dwMaxVisibleOverlays and try to create the number of overlay
surfaces that this parameters holds. There is no problem on systems
where the GPU provides only 1 for dwMaxVisibleOverlays (ie. my
8600GT). But there are some GPUs (like Ie Intel GMA X3300) that claims
to have dwMaxVisibleOverlays == 2. In that case the second call the
CreateSurface with DDSCAPS_OVERLAY fails returning DDERR_OUTOFCAPS.
Note that parameter DDCAPS::dwCurrVisibleOverlays is always 0, no
matter if there is already some video player playing to overlay. Note,
that there are no other applications that uses overlays at the same
time i run my program.
The problem dissapears, when I run my program in 2 instances, from
which every one creates only one overlay surface. It seems that there
is somehow non documented restriction (limitation) in DD7 that one
process is able to create only one overlay surface.
Here's some sample code (The problem occurs no matter what is the
dwWidth or dwHeight). If the ddcaps.dwMaxVisibleOverlays is 2, in
second loop the call to CreateSurface returns DDERR_OUTOFCAPS.
Can anybody help me?
Thanks
Dominik
DDSD ddsd;
memset(&ddsd, 0, sizeof ddsd);
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT |
DDSD_PIXELFORMAT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY;
ddsd.dwHeight = 320; // arbitrary values
ddsd.dwWidth = 200; // arbitrary values
// lock all available overlay surfaces
for ( int i=0; i<ddcaps.dwMaxVisibleOverlays; ++i )
{
LPDIRECTDRAWSURFACE7 lpOverlaySurface = NULL;
ddrval = m_lpDD->CreateSurface( &ddsd, &lpOverlaySurface,
NULL );
if( ddrval != DD_OK )
{
TRACE("Can't create overlay surface ! 0x%08lx\n", ddrval);
return(FALSE);
}
else
// keep the surface
{
m_listOverlaySurfaces.push_back
( CAdapt<CComPtr<IDirectDrawSurface7> >(CComPtr<IDirectDrawSurface7>
(lpOverlaySurface)) );
}
}