Jump to content
  • Advertisement
Sign in to follow this  
devronious

viewport help please...

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

the viewport object that is located in the current device has a maxz value that I can't seem to directly set. Is there a way to set this? Thanks, Devin

Share this post


Link to post
Share on other sites
Advertisement
These are set with pDevice->SetViewport().

Either query the current viewport, with GetViewport(), modify it, and set it back, or just create a temporary viewport like so:

D3DVIEWPORT9 vp;

vp.X = 0;
vp.Y = 0;
vp.Width = backbufferwidth; // same values you put in parameters sent to create device
vp.Height = backbufferheight;
vp.MinZ = 0;
vp.MaxZ = 1;

pDevice->SetViewport(&vp);

Z is still clipped and clamped as usual, but the final value is scaled to be between MinZ and MaxZ before testing and writing to the Z buffer. 0 and 1 are the standard settings. Setting both to 0 will cause any draws to appear in front of anything else. Unless you need the 0 stored in the Z buffer, it's probably quicker to just disable Z in this case. Setting both to 1 will cause all draws to appear behind anything else.

Share this post


Link to post
Share on other sites
If you're using managed code, you'll need to set the viewport property of the device:

Device.Viewport = vp;

Share this post


Link to post
Share on other sites
D3D likes to crash when setting a viewport when (x+width > backbufferwidth) or (y+height > backbufferheight). Are you sure you're passing valid sizes? Obviously when using a rendertarget the limits are the size of the render target, not the back buffer.

I'm not sure how D3D reacts to odd MinZ, MaxZ values, like values >1, <0, or Min>Max.

D3D might to extra validation if you turn on the debug runtimes (via control panel). With any luck, your output window should give details of the crash.

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.

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!