D3D9 / C++ : Present to different windows

Started by
3 comments, last by Namethatnobodyelsetook 17 years ago
Hi, I'm drawing to two seperate HWNDs at the same time, like so: BeginScene Draw first window's content EndScene Present with NULL (goes to main window) BeginScene Draw second window's content EndScene Present with HWND (draws to the other window). This seems to work rather nicely, except for the fact I'm using a V-synced (D3DPRESENT_INTERVAL_ONE) display, and each present waits for the vertical sync. My monitor runs at 75Hz, so unsurprisingly each window draws around the 37-38FPS mark. I'd like each window to present at full V-sync rate, 75fps for both. Is there a way to do this? Perhaps temporarily switch off waiting for V-sync? Thanks.
Construct (Free open-source game creator)
Advertisement
In the D3DPRESENT_PARAMETERS set the presentation interval property to D3DPRESENT_INTERVAL_IMMEDIATE.

Dave
If you use CreateAdditionalSwapChain to create a seperate backbuffer/present call for your other window, you may be able to get them to both vsync. I can't say I've ever tried vsync with swap chains, but it's the only way I can think of that *might* work.
@Dave: I want to vsync both windows, not run uncapped!

@Namethatnobodyelsetook: I've tried using CreateAdditionalSwapChain with D3DPRESENT_INTERVAL_IMMEDIATE (the main window still presents in vsynced). I then exchanged the standard IDirect3DDevice9::Present() with IDirect3DSwapChain9::Present. I just get junk dumped on to that HWND though. It displays properly with IDirect3DDevice9::Present(), but at the reduced framerate.

Am I missing something?
Construct (Free open-source game creator)
Swapchain present presents the backbuffer of the swapchain, which won't contain anything useful until you draw to it.

On Init
CreateDevice
Get backbuffer
Get depthstencilSurface
CreateSwapChain
Get swapchain backbuffer
Create depthbuffer (if swapchain backbuffer is a different size than device)

On draw:
BeginScene
SetRenderTarget/SetDepthStencilSurface to backbuffer/zbuffer for swap chain
SetViewport
Draw
swapchain present.
SetRenderTarget/SetDepthStencilSurface to backbuffer/zbuffer from device
SetViewport
Draw
device present
EndScene

You'll need to release the all these (swapchain backbuffer, swap chain zbuffer, swapchain, device backbuffer, and device zbuffer) on lost device, and recreate them when you get the device back. I usually set the device's rendertarget and z back as the activce ones before I release the pointers, but I have no idea if that's necessary.

This topic is closed to new replies.

Advertisement