• ### Popular Now

• 11
• 9
• 10
• 9
• 10

#### Archived

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

# Z Buffer issues

This topic is 5065 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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.

##### Share on other sites
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

##### Share on other sites
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...