Skip to main content
gamedev.net
🔒 Locked

Z Buffer issues

Started by Sr_Guapo Jun 8, 2004 at 10:14 PM 2 replies 750+ views
Original Post
Sr_Guapo
Sr_Guapo
Hi, I am currently trying to upgrade from DX8 to managed DX9. I wrote a very small program that loaded a simple sphere (created in Milkshape), and renderened it to the screen, nothing else... Anyway, when I implemented the Z-Buffer:
d3dpp.EnableAutoDepthStencil = True ''// Depth stencil
d3dpp.AutoDepthStencilFormat = DepthFormat.D16
 
I got very strange results (very pixelly looking... its hard to explain). Any way, I then realized I forgot to clear the buffer (hehe...), but when I do that, I get no display... The code to do that is:
D3DDevice.Clear(ClearFlags.Target or ClearFlags.ZBuffer, Color.Black, 0, 0)
 
I assume I did something wrong, but I don''t know what... Any help is greatly appreciated.
Sean Henley [C++ Tutor]Rensselaer Polytechnic Institute
3DXD
3DXD
A couple possibly stupid questions.

1. Did you set the zbuffer state to enabled?
2. Did you accidentally move out of the near/far clip plane regions so you see nothing
3. When you say you "enabled" the Z buffer, how did you get the file rendered before. since it was a sphere, did you have no Z values in your Directx 8 version?
4. What about your camera/project/world matrices are you sure they are correct.
5. Is there any errors possibly occuring you aren''t catching(meaning just step through and make sure the rendering works etc).

I have a similar project that loads just a directx mesh and it does work, but I am not much of a real expert to be honest, although if I saw the code I could compare it to mine and tell you what i don''t see.
DrunkenHyena
DrunkenHyena
Clearing the ZBuffer to 0 sets all positions to be closest to the camera. This is the opposite of what you want. Try setting it to 1.0.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena</FON
Sr_Guapo
Sr_Guapo
yes... It was a stupid mistake... I just changed this line:

D3DDevice.Clear(ClearFlags.Target or ClearFlags.ZBuffer, Color.Black, 0, 0)

to this:

D3DDevice.Clear(ClearFlags.Target or ClearFlags.ZBuffer, Color.Black, 1.0F, 0)

that is really embarrassing...
Sean Henley [C++ Tutor]Rensselaer Polytechnic Institute

Topic Locked

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

Sign in to reply to this topic.