Sign in to follow this  
AshleysBrain

D3D9 / C++ : Present to different windows

Recommended Posts

AshleysBrain    162
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
AshleysBrain    162
@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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this