Platform SDK: DirectX |
You usually create a depth buffer during your application's startup sequence, before creating a Direct3D device object for rendering. Use the following steps to create and attach a depth buffer surface to the render-target surface.
To create a depth buffer in a C++ application
After creating the depth buffer surface and attaching it to the render-target surface, call the IDirect3D7::CreateDevice method to create a rendering device that uses the render-target surface and its depth buffer.
Create the depth buffer in video memory—with the DDSCAPS_VIDEOMEMORY surface capability—when your application uses a hardware driver (HAL device), and in system memory—the DDSCAPS_SYSTEMMEMORY surface capability—when using software emulation drivers (the MMX or RGB devices). Failing to create a depth buffer in the appropriate type of memory will cause the CreateDevice method to fail.
Note Some popular hardware devices require that the render target and depth buffer surfaces use the same bit depth. On such hardware, if your application uses a 16-bit render-target surface, the attached depth buffer must also be 16-bits. For a 32-bit render-target surface, the depth buffer must be 32-bits, of which 8-bits can be used for stencil buffering (if needed).
If the hardware upon which your application is running has this requirement, and your application fails to meet it, any attempts to create a rendering device that uses the non-compliant surfaces will fail. You can use the DirectDraw method, IDirectDraw7::GetDeviceIdentifier to track hardware that imposes this limitation.
To create a depth buffer in a Visual Basic application
After creating the depth buffer surface and attaching it to the render-target surface, call Direct3D7.CreateDevice to create a rendering device that uses the render-target surface and its depth buffer.
Create the depth buffer in video memory—with the DDSCAPS_VIDEOMEMORY surface capability—when your application uses a hardware driver (HAL device), and in system memory—the DDSCAPS_SYSTEMMEMORY surface capability—when using software emulation drivers (the MMX or RGB devices). Failing to create a depth buffer in the appropriate type of memory will cause the CreateDevice method to fail.
Note Some popular hardware devices require that the render target and depth buffer surfaces use the same bit depth. On such hardware, if your application uses a 16-bit render-target surface, the attached depth buffer must also be 16-bits. For a 32-bit render-target surface, the depth buffer must be 32-bits, of which 8-bits can be used for stencil buffering (if needed).
If the hardware upon which your application is running has this requirement, and your application fails to meet it, any attempts to create a rendering device that uses the non-compliant surfaces will fail. You can use the DirectDraw method, DirectDraw7.GetDeviceIdentifier and the associated object (DirectDrawIdentifier) to track hardware that imposes this limitation.