What's New in IDirectDrawSurface2?
The COM model that DirectX uses specifies that new functionality can be added by providing new interfaces. The IDirectDrawSurface2 interface supersedes the IDirectDrawSurface interface. This new interface can be obtained by using the IDirectDraw::QueryInterface method, as shown in the following example:
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, as well as three new methods: IDirectDrawSurface2::GetDDInterface, IDirectDrawSurface2::PageLock, and IDirectDrawSurface2::PageUnlock.