Sign in to follow this  

viewport help please...

Recommended Posts

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:


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;


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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this