Jump to content
  • Advertisement
Sign in to follow this  
AshleysBrain

D3D9 / C++ : Present to different windows

This topic is 4114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
In the D3DPRESENT_PARAMETERS set the presentation interval property to D3DPRESENT_INTERVAL_IMMEDIATE.

Dave

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
@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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!