Microsoft DirectX 9.0


The AddAttachedSurface method attaches a surface to another surface.

Examples of possible attachments include z-buffers, alpha channels, and back buffers. Some attachments automatically break other attachments. For example, the 3DZBUFFER can only be attached to one back buffer at a time. Attachment is not bidirectional, and a surface cannot be attached to itself. Emulated (system memory) surfaces cannot be attached to nonemulated surfaces. Unless one surface is a texture map, the two attached surfaces must be the same size. A flippable surface cannot be attached to another flippable surface of the same type, however it is allowable to attach two surfaces of different types; for example, a flippable Zbuffer can be attached to a regular flippable surface. If a non-flippable surface is attached to another non-flippable surface of the same type, the two surfaces will become a flippable chain. If a non-flippable surface is attached to a flippable surface, it becomes part of the existing flippable chain. Additional surfaces can be added to this chain, and each call of the Flip method will cycle one step through the surfaces.


HRESULT AddAttachedSurface(



Points to the DIRECTDRAWSURFACE that is to be attached.

Return Values

Value Description
DD_OK The method succeeded.
DDERR_INVALIDOBJECT DirectDraw received a pointer that was an invalid DirectDraw object.
DDERR_GENERIC Generic failure.
DDERR_SURFACELOST Access to this surface is being refused because the surface memory is gone. The DirectDrawSurface object representing this surface should have Restore called on it.
DDERR_INVALIDPARAMS One or more of the input parameters is invalid.
DDERR_SURFACEALREADYATTACHED This surface is already attached to the surface it is being attached to.
DDERR_WASSTILLDRAWING Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is incomplete.
DDERR_CANNOTATTACHSURFACE This surface can not be attached to the requested surface.

See Also