IDirectDrawSurface2 Interface

The COM model that DirectDraw uses specifies that new functionality can be added by providing new interfaces. This release of DirectDraw implements two new interfaces, the IDirectDraw2 Interface and the IDirectDrawSurface2 Interface.

The following example shows how to create an IDirectDrawSurface2 interface:

LPDIRECTDRAWSURFACE lpSurf;

LPDIRECTDRAWSURFACE2 lpSurf2;

// Create surfaces

memset( &ddsd, 0, sizeof( ddsd ) );

ddsd.dwSize = sizeof( ddsd );

ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;

ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN |

DDSCAPS_SYSTEMMEMORY;

ddsd.dwWidth = 10;

ddsd.dwHeight = 10;

ddrval = lpDD2->CreateSurface( &ddsd, &lpSurf,

NULL );

if( ddrval != DD_OK )

return;

ddrval = lpSurf->QueryInterface(

IID_IDirectDrawSurface2, (LPVOID *)&lpSurf2);

if( ddrval != DD_OK )

return;

ddrval = lpSurf2->PageLock( 0 );

if( ddrval != DD_OK )

return;

ddrval = lpSurf2->PageUnlock( 0 );

if( ddrval != DD_OK )

return;

The IDirectDrawSurface2 interface contains all of the methods provided in the IDirectDrawSurface interface, along with three new methods: IDirectDrawSurface2::GetDDInterface, IDirectDrawSurface2::PageLock, and IDirectDrawSurface2::PageUnlock.

For more information on obtaining the IDirectDraw2 interface, see IDirectDraw2 Interface.