DDRM.EXE: Mixing 2-D DirectDraw Objects With Direct3DID: Q152646
|
The DDRM sample demonstrates one method of combining 2-D objects on a DirectDraw surface, such as a background, with Direct3D Retained Mode. It also demonstrates how to lock the primary surface's palette down and how to force Retained Mode to utilize what is in the palette and leave the entries in it unchanged. Since the palette will not change, the pixels of the 2-D objects you create will not have to change. This sample renders to a full screen, 8 bit-per-pixel DirectDraw surface using double buffering.
The following file is available for download from the Microsoft Software Library:
~ DDRM.EXEFor more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
Q119591 How to Obtain Microsoft Support Files from Online Services
DDCOLORKEY ddck;
ddck.dwColorSpaceLowValue = 255;
ddck.dwColorSpaceHighValue = 255;
lpDDSBack->SetColorKey(DDCKEY_DESTBLT, &ddck);
After this is done, CreateDeviceFromSurface() is called to create a
Retained Mode device for the back buffer.
{
HRESULT ddrval;
RECT rcRect;
DDBLTFX ddBltFx;
rcRect.left = 0;
rcRect.top = 0;
rcRect.right = 640;
rcRect.bottom = 480;
// Clear the back buffer
ZeroMemory(&ddBltFx,sizeof(DDBLTFX));
ddBltFx.dwSize = sizeof(DDBLTFX);
ddBltFx.dwFillColor = 255;
lpDDSBack->Blt(NULL,NULL,NULL,DDBLT_COLORFILL | DDBLT_WAIT;
,&ddBltFx);
// Update the 3D Retained Mode scene
scene->Move(D3DVALUE(1.0));
view->Clear();
view->Render(scene);
rmdev->Update();
// Use DDBLTFAST_DESTCOLORKEY to blit the 2D bitmap image onto the
// scene, only updating the white pixels
while( (ddrval = lpDDSBack->BltFast( 0, 0, lpDDSOne, &rcRect,
DDBLTFAST_DESTCOLORKEY ) ) == DDERR_WASSTILLDRAWING );
// Update the primary surface
while(lpDDSPrimary->Flip( NULL,0 ) == DDERR_WASSTILLDRAWING);
}
NOTE: In this version of Direct3D, you should not change the palette on your primary surface or your back buffer. Retained Mode will not account
for the palette entry changes. Microsoft is aware of this problem. The DDRM
sample demonstrates this problem by allowing you to change the palette
while it is executing.
DirectDraw code from portions of the DDEX3 sample was used in parts of this sample.
Additional query words: kbgraphic kbfile Direct3D
Keywords : kbfile kbsample kbSDKWin32 kbWinOS95 kbDirectX200
Version : WINDOWS:2.0,95
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: June 21, 1999