Original Post
When I use the following code nothing appears if the ZBuffer is enabled... The display is in a picturebox located within a VB form... Can anyone see what I am doing wrong... so that I can use a Z buffer.
In the Debug Window it says it is choosing the 32 bit Depth buffer but i have tried it with all the buffers to no avail
[edited by - willywig on August 9, 2002 11:49:17 AM]
Call D3D.GetAdapterDisplayMode(D3DADAPTER_DEFAULT, DispMode)
D3DWindow.Windowed = 1
D3DWindow.BackBufferCount = 1
D3DWindow.BackBufferFormat = DispMode.Format
D3DWindow.BackBufferWidth = DispMode.Width
D3DWindow.BackBufferHeight = DispMode.Height
D3DWindow.hDeviceWindow = Picture1.hWnd
D3DWindow.AutoDepthStencilFormat = D3DFMT_D16
D3DWindow.EnableAutoDepthStencil = 1
D3DWindow.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
If D3D.CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DispMode.Format, _
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D32) = D3D_OK Then
'//Enable a pure 32bit Depth buffer
D3DWindow.AutoDepthStencilFormat = D3DFMT_D32
D3DWindow.EnableAutoDepthStencil = 1
Debug.Print "32 bit Depth buffer selected"
Else '//search for a 24 bit depth buffer
If D3D.CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DispMode.Format, _
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X8) = D3D_OK Then
'//Enable a 24 bit depth buffer
D3DWindow.AutoDepthStencilFormat = D3DFMT_D24X8
D3DWindow.EnableAutoDepthStencil = 1
Debug.Print "24 bit Depth buffer selected"
Else
If D3D.CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DispMode.Format, _
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16) = D3D_OK Then
'//Enable a 16 bit depth buffer
D3DWindow.AutoDepthStencilFormat = D3DFMT_D16
D3DWindow.EnableAutoDepthStencil = 1
Debug.Print "16 bit Depth buffer selected"
Else '//hmm. No depth buffers available... Dont use one then :)
D3DWindow.EnableAutoDepthStencil = 0
Debug.Print "no Depth buffer selected"
End If
End If
End If
Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Picture1.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow)
D3DDevice.SetVertexShader Lit_FVF
D3DDevice.SetRenderState D3DRS_LIGHTING, False
D3DDevice.SetRenderState D3DRS_CULLMODE, D3DCULL_NONE
'// enable our Z Buffer
D3DDevice.SetRenderState D3DRS_ZENABLE, 1