The IDirectDrawSurface4::AddAttachedSurface method attaches the specified surface to this surface.
HRESULT AddAttachedSurface(
LPDIRECTDRAWSURFACE4 lpDDSAttachedSurface
);
If the method succeeds, the return value is DD_OK.
If the method fails, the return value may be one of the following error values:
DDERR_CANNOTATTACHSURFACE |
DDERR_GENERIC |
DDERR_INVALIDOBJECT |
DDERR_INVALIDPARAMS |
DDERR_SURFACEALREADYATTACHED |
DDERR_SURFACELOST |
DDERR_WASSTILLDRAWING |
This method increments the reference count of the surface being attached. You can explicitly unattach the surface and decrement its reference count by using the IDirectDrawSurface4::DeleteAttachedSurface method. Unlike complex surfaces that you create with a single call to IDirectDraw4::CreateSurface, surfaces attached with this method are not automatically released. It is the application's responsibility to release such surfaces.
Possible attachments include z-buffers, alpha channels, and back buffers. Some attachments automatically break other attachments. For example, the 3-D z-buffer can be attached only to one back buffer at a time. Attachment is not bidirectional, and a surface cannot be attached to itself. Emulated surfaces (in system memory) cannot be attached to nonemulated surfaces. Unless one surface is a texture map, the two attached surfaces must be the same size. A flipping surface cannot be attached to another flipping surface of the same type; however, attaching two surfaces of different types is allowed. For example, a flipping z-buffer can be attached to a regular flipping surface. If a nonflipping surface is attached to another nonflipping surface of the same type, the two surfaces will become a flipping chain. If a nonflipping surface is attached to a flipping surface, it becomes part of the existing flipping chain. Additional surfaces can be added to this chain, and each call of the IDirectDrawSurface4::Flip method will advance one step through the surfaces.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Header: Declared in ddraw.h.
Import Library: Use ddraw.lib.
IDirectDrawSurface4::DeleteAttachedSurface, IDirectDrawSurface4::EnumAttachedSurfaces