Archived

This topic is now archived and is closed to further replies.

markdezonia

ZBUFFER will not work

Recommended Posts

markdezonia    122
My zbuffer will not work and I get no errors. It could be my code , but what other things could be going wrong? this code worked before now it does not. I had to reinstall windows and directx recently could my video driver be corrupt. could a pointer or string effect my zbuffer with out an exception or crash. heres the code for just for the zbuffer. Any ideas or suggestion would be greatly appreciated; D3DPRESENT_PARAMETERS d3dpp; D3DDISPLAYMODE d3ddm; if( NULL == (g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )return E_FAIL; g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddm); ZeroMemory( &d3dpp, sizeof(d3dpp)); d3dpp.BackBufferWidth=d3ddm.Width; d3dpp.BackBufferHeight=d3ddm.Height; d3dpp.Windowed = false; d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP; d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.BackBufferCount=0; d3dpp.hDeviceWindow=hWnd; d3dpp.FullScreen_RefreshRateInHz=D3DPRESENT_RATE_DEFAULT; d3dpp.PresentationInterval =D3DPRESENT_INTERVAL_IMMEDIATE ; if( FAILED(g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_MULTITHREADED|D3DCREATE_SOFTWARE_VERTEXPROCESSING , &d3dpp, &g_pd3dDevice )) ) void RENDER() { g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER ,color,1.0f,0); g_pd3dDevice->BeginScene(); //render stuff; g_pd3dDevice->EndScene(); g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }

Share this post


Link to post
Share on other sites
Aeroum    122
What about...

g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);

or if you are using w buffer

g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_USEW);

As for whether or not you think something is corrupt, try running some DirectX samples or other 3D games and see if they ZBuffer properly.

-Aeroum

Share this post


Link to post
Share on other sites