Multiple viewports in D3D9

Started by
4 comments, last by sirob 19 years, 5 months ago
I need to have the same geometry rendered with two different cameras, in two viewports how can i do this?
Cartman's definition of sexual harrasement:"When you are trying to have intercourse with a lady friend, and some other guy comes up and tickles your balls from behind"(watch South Park, it rocks)
Advertisement
With D3DVIEWPORT9. I can't provide more information, gotta go..
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.
[size=2]aliak.net
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.
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?
Cartman's definition of sexual harrasement:"When you are trying to have intercourse with a lady friend, and some other guy comes up and tickles your balls from behind"(watch South Park, it rocks)
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.
Sirob Yes.» - status: Work-O-Rama.

This topic is closed to new replies.

Advertisement