Jump to content
  • Advertisement

Archived

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

Talisman

SetViewport MinZ and MaxZ problem

This topic is 6188 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

Hi, I want to use MinZ ans MaxZ in SetViewport function to render a polygon which will clear the z-buffer with the value I want, by setting MinZ ans MaxZ to this value. The SetViewport call works and a call to GetViewport tell me that paramaters are the good ones. But on screen, nothing change, as if MinZ = 0.0 and MaxZ = 1.0. I use the same technique in OpengL with glDepthRange and it works perfectly. Is this a DirectX bug ? a wrong render state ? ... Eric

Share this post


Link to post
Share on other sites
Advertisement
Instead of rendering a polygon to clear the z buffer, why don't you just... clear the z buffer?

pDevice->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0, MyNewValue, 0);

I don't think SetViewport renders anything or changes the current buffer contents (if I understand you correctly), it justs sets up the device for subsequent rendering. (it's been awhile, but I think SetViewport in OpenGL does more under the hood than in DX8)

In both OpenGL and DX, calling clear is much more efficient than rendering a rectangle if you are actually just clearing.

Edited by - CrazedGenius on August 7, 2001 10:25:04 AM

Share this post


Link to post
Share on other sites
I am agree that clear the z buffer is more efficient but the region to clear is not a rectangle, it is a surface generated by the projection of a striped polygon.
SetViewport change the projection matrix and the viewport matrix. If Minz and Maxz = 1.0, then, z value after projection which is between -1.0 and 1.0 will be transform between 1.0 and 1.0 so 1.0 for the final value, the one which will be written in the z buffer. That''s what happen in OpenGL but not in DirectX. The value written in the z buffer apear to be in the range 0.0, 1.0. :-(

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!