|
|
|
|
![]() ![]() |
Oct 8 2006, 09:24 PM
Post
#1
|
|
|
Way Out Of Control - You need a life :) Group: Members Posts: 1,366 Joined: 14-September 04 From: Nottingham England Member No.: 570 |
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 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. |
|
|
|
Nov 14 2006, 09:22 AM
Post
#2
|
|
|
Premium Member Group: [HOSTED] Posts: 474 Joined: 5-November 06 Member No.: 17,016 |
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/technet/sysinternals/utilities/debugview.mspx), 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 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. |
|
|
|
Jun 25 2008, 01:51 AM
Post
#3
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
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 |
|
|
|
Jul 24 2008, 06:28 AM
Post
#4
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
Replying to faulty.Lee
You also need to set some parameters in your D3DPRESENT_PARAMETERS struct D3dpp.EnableAutoDepthStencil = TRUE; D3dpp.AutoDepthStencilFormat = D3DFMT_D16; And to clear make you are doing something like this Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); -reply by saus |
|
|
|
Jul 24 2008, 06:28 AM
Post
#5
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
Replying to faulty.Lee
You also need to set some parameters in your D3DPRESENT_PARAMETERS struct D3dpp.EnableAutoDepthStencil = TRUE; D3dpp.AutoDepthStencilFormat = D3DFMT_D16; And to clear make you are doing something like this Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); -reply by saus |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 30th August 2008 - 05:31 PM |