IDirectDrawSurface::Flip

HRESULT Flip(

LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride,

DWORD dwFlags);

Makes the surface memory associated with the DDSCAPS_BACKBUFFER surface become associated with the front buffer surface.

·Returns DD_OK if successful, or one of the following error values otherwise:

DDERR_GENERIC DDERR_INVALIDOBJECT
DDERR_INVALIDPARAMS DDERR_NOTFLIPPABLE
DDERR_NOFLIPHW DDERR_SURFACEBUSY
DDERR_SURFACELOST DDERR_WASSTILLDRAWING
DDERR_UNSUPPORTED  

lpDDSurfaceTargetOverride

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

dwFlags

DDFLIP_WAIT

Typically, if the flip cannot be set up because the state of the display hardware is not appropriate, the error DDERR_WASSTILLDRAWING will return immediately and no flip will occur. Setting this flag causes IDirectDrawSurface::Flip to continue trying to flip if it receives the DDERR_WASSTILLDRAWING error from the HAL. IDirectDrawSurface::Flip will not return until the flipping operation has been successfully set up, or if another error, such as DDERR_SURFACEBUSY, is returned.

This method can only be called by a surface that has the DDSCAPS_FLIP and DDSCAPS_FRONTBUFFER values set. The display memory previously associated with the front buffer is associated with the back buffer. If there is more than one back buffer, a ring is formed and the surface memory buffers cycle one step through it every time IDirectDrawSurface::Flip is invoked.

The lpDDSurfaceTargetOverride parameter is used in rare cases when the back buffer is not the buffer that should become the front buffer. Typically this parameter is NULL.

The IDirectDrawSurface::Flip method will always be synchronized with the vertical blank.