   DX10 + DXUT and depth stencil problems
  I am trying to follow the tutorials included in the DirectX SDK but i have run into a problem.I used DXUT to render a mesh and drew a cube manually.  If I render the cube then the mesh the mesh is always on top and vice versa.I am pretty sure that I am clearing the depth stencil buffer each frame:void CALLBACK OnD3D10FrameRender( ID3D10Device* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ){    //    // Clear the back buffer    //    float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; // red, green, blue, alpha    ID3D10RenderTargetView* pRTV = DXUTGetD3D10RenderTargetView();    pd3dDevice->ClearRenderTargetView( pRTV, ClearColor );    // If the settings dialog is being shown, then    // render it instead of rendering the app's scene    if( g_D3DSettingsDlg.IsActive() )    {   g_D3DSettingsDlg.OnRender( fElapsedTime );   return;    }    //    // Clear the depth stencil    //    ID3D10DepthStencilView* pDSV = DXUTGetD3D10DepthStencilView();    pd3dDevice->ClearDepthStencilView( pDSV, D3D10_CLEAR_DEPTH, 1.0, 0 );    ....    Render Cube    Render Mesh}But I still cannot seem get them to overlap properly.[Edited by - jchmack on May 22, 2009 8:15:54 PM]
  Do you have depth testing and depth writing turned on?  Check to see that you are!  Also, take a frame with PIX and inspect the contents of your depth buffer before and after your draw calls.  This should show you what is going on with the depth buffer.   ;Quote:Original post by Jason ZDo you have depth testing and depth writing turned on?  Check to see that you are!  Also, take a frame with PIX and inspect the contents of your depth buffer before and after your draw calls.  This should show you what is going on with the depth buffer.I am letting DXUT initialize everything for me:    DXUTCreateWindow( L"Test APP" );    DXUTCreateDevice( true, 640, 480 );I had assumed that DXUT would use the default behavior for the stencil bufferfrom the SDK tutorials:Quote: The default behavior of the depth buffer in Direct3D 10 is to check every pixel being drawn to the screen against the value stored in the depth buffer for that screen-space pixel. If the depth of the pixel being rendered is less than or equal to the value already in the depth buffer, the pixel is drawn and the value in the depth buffer is updated to the depth of the newly drawn pixel. On the other hand, if the pixel being draw has a depth greater than the value already in the depth buffer, the pixel is discarded and the depth value in the depth buffer remains unchanged.I spent some time looking through the DXUT source and I cannot tell if microsoft enables depth testing and depth writing by default.  It initializes directx 9 settings and then converts them into 10.  I honestly don't know enough about either at this point.Does anyone know?  How can I check?   ;  There is a get depth stencil state method.I think they lied too. The default appears to be less than, not less than or equal. I would totally dump all use of DXUT, it is a smoldering heap of garbage and will only make things more confusing than they need to be.