Jump to content
  • Advertisement
Sign in to follow this  
caesar4

Multiple viewports in D3D9

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

Advertisement
yeah, with d3dviewport9. Pseudocode:

- Get current D3D9VIEWPORT: IDirect3DDevice9::GetViewport
- Create a viewport half the screen then set it.
- Draw the stuff from one camera
- Create viewport for second half of screen and set it
- Draw from the other camera
- Restore original viewport.

Share this post


Link to post
Share on other sites
A viewport lets you clip the rendered geometry to a certain area on the screen.

If you are thinking of something like a flight simulator with a MFD (like infrared display from the missles warhead in the cockpit) you would first render the first display with a fullscreen viewport. Then set a new viewport on the screen, clear it, then render the scene with the new camera in the new viewport.



D3DVIEWPORT9 vp;

vp.X = 0;
vp.Y = 0;
vp.Width = 800;
vp.Height = 600;
vp.MinZ = 0;
vp.MaxZ = 1;

p_Device->SetViewport(&vp);





Sorry for the redundant info, IFooBar beat me to it.

Share this post


Link to post
Share on other sites
Quote:
Original post by IFooBar
yeah, with d3dviewport9. Pseudocode:

- Get current D3D9VIEWPORT: IDirect3DDevice9::GetViewport
- Create a viewport half the screen then set it.
- Draw the stuff from one camera
- Create viewport for second half of screen and set it
- Draw from the other camera
- Restore original viewport.


im drawing the same things for both viewports, only difference is the camera matrix
so would i still need to redraw everything for the second viewport?

Share this post


Link to post
Share on other sites
yes, you would, since drawing it again is what actually updates whats on the screen.

you:
- Do a full draw.
- Set the second viewport.
- Change the matrix for the camera.
- Redraw.

also, don't forget to set the viewport to the original one somewhere before drawing the next frame.

Also, if you plan on splitting the screen into two sections, consider doing the first draw to only the first half of the screen - not all of it (again, using a viewport set to the other part of the screen). This will make your drawing faster, since you don't draw any pixels twice.

Also, you need to update any clipping or culling code you have to reflect the changes in camera position/direction.

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!