Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multiple windows one device?

Started by bmccall Feb 6, 2009 at 2:45 PM 3 replies 900+ views
Original Post
bmccall
bmccall
Hello Everyone: I have a decent question. I am expanding a DirectX 3D Win32 application. I have created a child window off of the main window. My problem is that the device is rendering to the main window the 3D graphics I need tha child window to show some 2D debug info (squares, circles and text). My device can already render that stuff but I dont know how to render to the child window with the device that is currently rendering to the main window. Someone told me to use viewports. Does anyone have some insight on this? I was thinking that I could create another device and apply it to the child window. Any help is appreciated.
SiCrane
SiCrane
You don't need to create an additional device for the child window. When dealing with multiple windows you can use CreateAdditionalSwapChain() to create a swap chain, use GetBackBuffer() to get a render target for that swap chain and then use SetRenderTarget() for that swap chain when you render your windows. (Edit: using vanilla DirectX 9 anyways.)
TomKQT
TomKQT
Quote:
Original post by Black Knight
Does this mean all textures vertexbuffers etc. are shared between the main and child window?


Yep. You'll have just one device.
meZmo
meZmo
Actually, for d3d9 you don't even need to create multiple swap chains.

Just render and _present_ your scene once for each window, making sure your swapchain is at least as big as the largest window (full screen sized makes that easier), and that your viewport is correctly sized for each window's client rect. Then, when you invoke Device::Present, pass your window handle as an override to present to that specific window.

-meZ

Topic Locked

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

Sign in to reply to this topic.