Jump to content
  • Advertisement
Sign in to follow this  
pukas

DirectX 9 and MFC

This topic is 4871 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

Hey! I´m planning to write a very simple 3D viewer. The app. should be multi-document app. and I want to be able to have up to four 3D views/document. My question is, how should I organise my project? Should every 3DView (CView) have its own IDirect3DDevice and share a global IDirect3D Interface or should I put one IDirect3DDevice Interface in the Document to be shared with the 3DViews? /p

Share this post


Link to post
Share on other sites
Advertisement
You should use only one device, but create a swapchain and add the other views there. This allows you to share the loaded textures and other resources. You would have to load all resources for every single device otherwise.

Share this post


Link to post
Share on other sites
Ok, so one device/document, but how many swapchains can one device support? I read somewhere that a device can only support 2 swapchains?
/p

Share this post


Link to post
Share on other sites
I'm sorry to interrupt, but Endurion: how can you use one device to display more then one render targets? Is could heavily use this!

Thanks for your answer,
kp

Share this post


Link to post
Share on other sites
You can call CreateAdditionalSwapChain with the new presentation parameters, and these can also contain a different HWND.

I never used that myself though, so i could be off.

Another option: In the Present call you can provide an alternative HWND as target.

Share this post


Link to post
Share on other sites
I've created editor using MFC and DX.

You create IDirect3DDevice9 for main frame (main window). I've used SDI so my view was split in 4 parts each using its own IDirect3DSwapChain9 interface.

Don't forget to handle resizing!

Basicly, you can do one of the following:

1. One device
Create one device for main window and for each renderable window, set its HWND* in device->Present(0, hWnd, 0, 0) IIRC.

2. One device, multiple swap chains
Create device for main frame and swap chain for each view class.

3. Multiple devices
Create independant device for each view class.

Share this post


Link to post
Share on other sites
Thanks for your arswers guys!
Just one more:
why would I want to create multiple swap chains (and allocate more video memory) if I can simply point another hwnd to Present?

kp

Share this post


Link to post
Share on other sites
Presenting to another window means scaling the backbuffer from whatever size it is, to the new window's size. Swap chains allow you to create a second (and third, etc.) front and backbuffer of the dimensions you actually want. Also, if you're using a SWAPEFFECT_COPY instead of DISCARD, you're expecting the backbuffer to remain untouched. This is useful for partially updating a GUI window. With it's own swap chain you won't destroy the backbuffer the other part of your app is expecting to keep.

Basically, they're different windows, with different sizes and settings, and a swapchain allows you to treat them as such.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!