Jump to content
  • Advertisement
Sign in to follow this  
amtri

D3DFVF_XYZRHW and Z-buffering

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering whether somebody could clarify a problem I'm having. I have a window sizes 480 x 360, and a single vertex defined with D3DFVF_XYZRHW|D3DFVF_DIFFUSE. The coordinates are (330,371,10,1,color) where color is the byte equivalent of green. Since the z-coordinate is not between 0 and 1, I expected the point NOT to show because of z-clipping. I have set D3DRS_ZENABLE to D3D_ZBTRUE, so I expected the clipping to happen. Can anybody point me to what else I should be doing to enable z-buffering? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
I would expect it to be invisible because it's off your window, regardless of Z, but I'm sure there's a typo in there somewhere. ;)

When you create your device you can ask D3D to create a Z buffer for you, or you'll have to make one yourself. In the presentation parameters passed to CreateDevice, set EnableAutoDepthStencil to true, and set AutoDepthStencilFormat to D3DFMT_D24X8. After that, setting D3DRS_ZENABLE should be all that's required.

You can check on some other states that should be defaulted correctly. Set D3DRS_ZWRITEENABLE to true. Set D3DRS_ZFUNC to D3DCMP_LESSEQUAL.

Share this post


Link to post
Share on other sites
Sorry for the typo. In x-y space, it's inside the window :-)

I looked at my code very carefully, especially after reading your message (a typo!!).

It turns out I had an unitialized variable. Once I fixed that, everything seems to be ok.

Thanks. The advice was good... made me look for typos!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!