Skip to main content
GameDev.net gamedev.net
🔒 Locked

Depth Buffer Help

Started by Squirell Jul 9, 2004 at 7:52 AM 3 replies 450+ views
Original Post
Squirell
Squirell
I'm trying to enable depth buffering because I can see polygons behind other polygons but I can't get it working. Heres my code for it:


D3DPRESENT_PARAMETERS d3dpp; 
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed               = TRUE;
d3dpp.SwapEffect             = D3DSWAPEFFECT_COPY;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

if(FAILED(g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3dDevice)))
return E_FAIL;

d3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);   

If I change D3DRS_ZENABLE to false everything works (except for the fact I can see through walls and such) If I set it to true my polygons are rendered but have many of there pixels blacked out and in some cases not rendered at all (even when they should be i think) Any help would be really appreciated
Trip99
Trip99
Are you clearing it? You need something like:
gD3dDevice->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,D3DCOLOR_XRGB(255,255,255),1.0f,0);


See also: C:\Site\Toymaker\Games\html\z_buffer.html
------------------------See my games programming site at: www.toymaker.info
Squirell
Squirell
No, I'm not. Thanks for the help I will try that as soon as I get home
superpig
superpig
Quote:
Original post by Trip99
See also: C:\Site\Toymaker\Games\html\z_buffer.html


*ahem*

Somehow I don't think he'll be able to "see also" that. [wink]
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Trip99
Trip99
lol you are right, gave a local copy, it should of course be: http://www.toymaker.info/Games/html/z_buffer.html
------------------------See my games programming site at: www.toymaker.info

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.