The information in this article applies to:
SUMMARYThe 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. MORE INFORMATIONThe following file is available for download from the Microsoft
Download Center. Click the file name below to download the file: Ddrm.exeFor more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. The DDRM sample creates a 640x480 primary surface with one back buffer. It also creates a 640x480 offscreen surface, on which it stores a 2-D bitmap image. A palette is created for the 2-D image and the palette is associated with both the back buffer and the front buffer. It is necessary to associate the palette with the back buffer because the back buffer will be rendered to by Retained Mode. To lock down the palette, you must set the peFlags member of the PALETTEENTRY structure for all palette entries to D3DPAL_READONLY. This will let Retained Mode know that it can use but not change the entries in the palette. After obtaining a handle to the back buffer, a 16BPP z-buffer is created and attached to it. SetPalette() is called to attach the palette to the back buffer, and a destination color key for blit operations is created for the back buffer. The color key is palette index 255 (white), so when you blit to the back buffer, all pixels that are 255 (white) on the surface will be overwritten by the pixels on the surface you are blitting from. All other pixels will be preserved. Following is manner in which the destination color key is created:
After this is done, CreateDeviceFromSurface() is called to create a
Retained Mode device for the back buffer.
When setting up the scene for the Retained Mode device, you must set the background color to 255 (white). When doing this, anything you blit to the back buffer will overwrite the background of the Retained Mode scene. Calling SetSceneBackground(D3DRGB(1,1,1)) will set up the background properly if white is the destination color key. It is important that only the background in the 3-D scene contain white pixels. You should choose a background color (destination color key) you know will never be used on your 3-D objects. Following is the sequence of steps to take to update and render the display: 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.
REFERENCESDirectDraw code from portions of the DDEX3 sample was used in parts of this sample. Additional query words: kbgraphic kbfile Direct3D
Keywords : kbfile kbsample kbDirect3dRM KbDirectX kbSDKWin32 kbWinOS95 kbfaq kbDirectX200 |
Last Reviewed: January 21, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |