Jump to content
xisto Community
Sign in to follow this  
qwijibow

Direct3d Setrenderstate(d3drs_zenable,true) Has No Effect ? Depth Testing is not working

Recommended Posts

Hi, i've recently started working my way through a book on Using DirectX 9.0c SDK.
And i've noticed that Depth testing is not working on my first few programs, Nor is it working on the book's cd's demo applications ( even pre-compiled)

In other words, some objects are beeing drawn over the top of objects closer to the camera.

Very early in the book, ( Chapter 1 ) the book descibes this problem, and how to resolve it by enableing Depth testing using the Depth Buffer.

the solution it says is a single line of code

g_D3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE);

However, this seems to have no effect.. Distant objects are still beeing drawn over the top of some closer ones.

Any Idea's as to what is going on ?

I am using DirectX Runtime 9.0c
SDK 9.0c
Graphics Card is NVidia GeForce FX 5700 LE ( latest drivers )

The PRE-compiled programs on the CD were compiled with Visual Studio 2005.

I Was using GCC-3.4 (cygwin) compiler, but in an act of desperation, also attempted compiling with Microsoft Visual C++ Toolkit 2003.
which resulted with the same rendering issue !!!

HOWEVER... DirectX games all work fine.

Im hoping this must be due to a programming error..i have noticed one or two in the book... but i cant fint it, and MSDN states that that the single line of code above is the ONLY requirement for correct 3d depth rendering.

oes anyone have any ideas ???

unfortunatly, i am not able to past the demo application here, as i am not the author, and it is probably under some kind of copyright.

Share this post


Link to post
Share on other sites

You can refer to this site for more info on Z-Buffer http://www.toymaker.info/Games/html/z_buffer.html

Also, make sure you're using the debug version of directx runtime, so you can see the "extra" messages from directx regarding error or warning that you should take note.

If you are not using the debug function in the IDE, of can't get debug message from the IDE, then get DebugView from Sysinternal (http://www.microsoft.com/err/technet/sysinternals/), it will do the job. It helped me a lot, cause i'm using managed directx, and that won't show the debug messages in the IDE.

Hi, i've recently started working my way through a book on Using DirectX 9.0c SDK.And i've noticed that Depth testing is not working on my first few programs, Nor is it working on the book's cd's demo applications ( even pre-compiled)

In other words, some objects are beeing drawn over the top of objects closer to the camera.

Very early in the book, ( Chapter 1 ) the book descibes this problem, and how to resolve it by enableing Depth testing using the Depth Buffer.

the solution it says is a single line of code

g_D3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE);

However, this seems to have no effect.. Distant objects are still beeing drawn over the top of some closer ones.

Any Idea's as to what is going on ?

I am using DirectX Runtime 9.0c
SDK 9.0c
Graphics Card is NVidia GeForce FX 5700 LE ( latest drivers )

The PRE-compiled programs on the CD were compiled with Visual Studio 2005.

I Was using GCC-3.4 (cygwin) compiler, but in an act of desperation, also attempted compiling with Microsoft Visual C++ Toolkit 2003.
which resulted with the same rendering issue !!!

HOWEVER... DirectX games all work fine.

Im hoping this must be due to a programming error..i have noticed one or two in the book... but i cant fint it, and MSDN states that that the single line of code above is the ONLY requirement for correct 3d depth rendering.

oes anyone have any ideas ???

unfortunatly, i am not able to past the demo application here, as i am not the author, and it is probably under some kind of copyright.

Share this post


Link to post
Share on other sites

z-buffer

Direct3d Setrenderstate(d3drs_zenable,true) Has No Effect ?

 

No but I believe I'm making progress

 

Zenable

ZWRITEENABLE

D3ddev->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);

 

D3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

 

But I to still have nothing

 

-reply by matthew

Share this post


Link to post
Share on other sites
Replying to faulty.LeeYou also need to set some parameters in your D3DPRESENT_PARAMETERS structD3dpp.EnableAutoDepthStencil = TRUE;D3dpp.AutoDepthStencilFormat = D3DFMT_D16;And to clear make you are doing something like thisClear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);-reply by saus

Share this post


Link to post
Share on other sites
Replying to faulty.LeeYou also need to set some parameters in your D3DPRESENT_PARAMETERS structD3dpp.EnableAutoDepthStencil = TRUE;D3dpp.AutoDepthStencilFormat = D3DFMT_D16;And to clear make you are doing something like thisClear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);-reply by saus

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.