Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
A depth buffer is a property of the device. To create a depth buffer that is managed by Microsoft® Direct3D® Mobile, set the appropriate members of the D3DMPRESENT_PARAMETERSstructure as shown in the following code example.
Copy Code | |
---|---|
D3DMPRESENT_PARAMETERS d3dmpp; ZeroMemory( &d3dmpp, sizeof(d3dmpp) ); d3dmpp.Windowed = TRUE; d3dmpp.SwapEffect = D3DMSWAPEFFECT_COPY_VSYNC; d3dmpp.EnableAutoDepthStencil = TRUE; d3dmpp.AutoDepthStencilFormat = D3DMFMT_D16; |
By setting the EnableAutoDepthStencilmember to TRUE, you instruct Direct3D Mobile to manage depth buffers for the application. Note that AutoDepthStencilFormatmust be set to a valid depth buffer format. The D3DMFMT_D16 flag specifies a 16-bit depth buffer, if one is available.
The following call to the IDirect3DMobile::CreateDevicemethod creates a device that then creates a depth buffer.
Copy Code | |
---|---|
if( FAILED( g_pD3DM->CreateDevice( D3DMADAPTER_DEFAULT, D3DMDEVTYPE_HAL, hWnd, D3DMCREATE_MULTITHREADED, &d3dpp, &d3dDevice ) ) ) return E_FAIL; |
The depth buffer is automatically set as the render target of the device. When the device is reset, the depth buffer is automatically destroyed and recreated in the new size.
To create a new depth buffer surface, use the IDirect3DMobileDevice::CreateDepthStencilSurfacemethod.
To set a new depth-buffer surface for the device, use the IDirect3DMobileDevice::SetRenderTargetmethod.
To use the depth buffer in your application, you need to enable the depth buffer. For details, see Enabling Depth Buffering.