Original Post
ive set up my app to do depth buffering from what ive figured from tutorials and things, however, it clearly doesnt work.
heres a screen shot of it in its glory, rendering a wavy plane.
link
from what i figure, depth buffering will use a buffer containing depth values, and if a triangle's pixel value is lower, or closer to the screen, it will overwrite the existing value in the buffer. If this is the case, it wouldnt be necessary to sort and render triangles from back to front, right?
this is the code i use to set up the device:
D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = !fullscreen;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferFormat = (fullscreen)? D3DFMT_R5G6B5: D3DFMT_UNKNOWN;
if( fullscreen){
d3dpp.BackBufferWidth = width;
d3dpp.BackBufferHeight = height;
}
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
// Create the D3DDevice
if( FAILED( m_pDX->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &m_pD3DDevice ) ) )
{
return E_FAIL;
}
m_pD3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCL);
// Turn on the zbuffer
m_pD3DDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pD3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
Am i doing anything wrong or missing something?
[edited by - evilcrap on May 4, 2004 1:13:03 AM]
[edited by - evilcrap on May 4, 2004 1:13:52 AM]