Skip to main content
gamedev.net
🔒 Locked

rendering multiple viewports

Started by sepul 2 replies 1.4k views
Original Post
sepul
sepul
hi I want to render into multiple viewports, I went through the sdk and read something about creating swap chains and other stuff. but I don't know how it exactly works. how can I render multiple camera views into each viewport ? is there any article or sample code on this ? thanks
jollyjeffers
jollyjeffers
There are two ways to do what you want.

Firstly, Fullscreen mode
This is the simplest way of doing things - I've used it a few times before and its worked well for me. Also, as per the documentation: Note that any given device can support only one full-screen swap chain.

Look into the D3DVIEWPORT9 structure - setting this to represent the portion of your screen that you currently want to render.

So, if you want split-screen (say, top and bottom halves) then configure a D3DVIEWPORT9 to represent the top-half of your screen (the Width and Height fields are in pixels) and then commit it to the device using IDirect3DDevice9::SetViewport( ). Now render everything you want to appear in the top-half of your screen.

Now, do a similar option, but configure the D3DVIEWPORT9's Y parameter to represent the bottom half of your screen. Render everything again as appropriate.

Secondly, Windowed mode

You are on the right track by looking at 'swap chains' (IDirect3DSwapChain9 more specifically).

Typically what you'd do is create additional hWnd's so that you can specify them in the D3DPRESENT_PARAMETERS::hDeviceWindow field.

It's been a while since I've done this, but iirc, you use the various IDirect3DSurface9 pointers exposed by IDirect3DSwapChain9 as inputs to your current IDirect3DDevice9 in order to tell D3D that you want to render to a specific window...

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
smittix
smittix
You might want to check out some of the examples on this page. I've found them to be quite helpful myself.

http://www.codesampler.com/dx9src.htm

-Chris
sepul
sepul
thanks guys, I've solved it with your help and the sample source.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.