Microsoft DirectX 9.0

IDirectDrawSurface::Flip

The Flip method makes the surface memory associated with the DDSCAPS_BACKBUFFER surface become associated with the FRONTBUFFER surface. This method can only be called by a surface that has the DDSCAPS_FLIP and DDSCAPS_FRONTBUFFER bits set. The video memory previously associated with the front buffer is associated with the back buffer. If there is more than one back buffer, then a ring is formed and the surface memory buffers cycle one step through it every time Flip is invoked.

The TargetOverride parameter is used in rare cases where the BACKBUFFER is not the buffer that should become the FRONTBUFFER.  Normally it is NULL.

Flip will always be synchronized with the vertical blank.

Syntax

HRESULT Flip(
  LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride,
  DWORD dwFlags
  );

Parameters

lpDDSurfaceTargetOverride

Points to the IDirectDrawSurface interface of the surface that is to be flipped to. The default for this parameter is NULL, in which case Flip cycles through the buffers in the order they are attached to each other. This parameter is only used as an override.

dwFlags

Can be 0 or the following value.

Value Description
DDFLIP_WAIT Normally, if the Flip method cannot be set up because the state of the video hardware is not appropriate, the error DDERR_WASSTILLDRAWING will be returned immediately and no flip will occur. Setting this flag will cause Flip to continue trying if it receives the DDERR_WASSTILLDRAWING error from the HAL. Flip will not return until the flipping operation has been successfully set up or another error, such as SURFACEBUSY, has occurred.

Return Values

Value Description
DD_OK The method succeeded.
DDERR_INVALIDPARAMS One or more of the input parameters is invalid.
DDERR_INVALIDOBJECT DirectDraw received a pointer that was an invalid DirectDraw object.
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_SURFACEBUSY Access to this surface is being refused because the surface is already locked by another thread.
DDERR_GENERIC Generic failure.
DDERR_WASSTILLDRAWING Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is incomplete.
DDERR_UNSUPPORTED Action not supported.
DDERR_NOTFLIPPABLE An attempt has been made to flip a surface that is not flippable.
DDERR_NOFLIPHW Flipping visible surfaces is not supported.

See Also