Thread: Rendering into multiple windows

  1. #1
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001

    Rendering into multiple windows

    For my editor I'm wanting to render a main view and then some simple tile selection views. The tile selections will be part of a CPropertyPage in MFC that has a CWnd with a IDirect3DSwapChain9 interface pointer in it.

    For each window do I have to CreateAdditionalSwapChain() and then call IDirect3DSwapChain9::Present() for each window?

    In essence my render would look like this in CEditor3D, which is the main class where everything happens.

    CEditorView::OnDraw() calls virtual CEditor3D::Render() which looks like this:

    void CEditor3D::Render(float fTimeDelta)
      //Render main view using D3DPRESENT_PARAMETERS
         m_pDevice->Clear(0,0,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,0,1.0f,0);
      //Render all windows
    for (unsigned int i=0;i<m_vWindowList.size();i++)
         m_pDevice->Clear(0,0,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,0,1.0f,0);
    Is this the correct way?

    This is confusing but there isn't any message loop for the Direct3D window. When I initialize my Direct3D I specify that it is windowed and that it does not need to create a window. It just uses the one I supply. So essentially it's just a render window with no associated message loop. The message loop is inside of MFC's doc/view architecture and inside of that I can fire off a thread that is solely responsible for calling CEditor3D::Render().
    But for now it's only updated when MFC calls CView::OnDraw() which works just fine.

    For those of you who know what I'm talking about...does this seem like a logical way to render to multiple MFC windows (CPropertyPages) as well as one main CView?

    This is an SDI app.
    Last edited by VirtualAce; 03-31-2006 at 05:42 AM.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    I've never used MFC, but that's basically how I do it. I only call GetBackBuffer once though (or when the window is resized so it has to be reset). Also, you may need a separate Z-buffer for each swap chain using CreateDepthStencilSurface() and SetDepthStencilSurface(), I got some might odd bugs when using the same for all my windows.

    Oh, and I usually use an invisible dummy window as the main render target so all my windows use the same swap-chaining code. Not an elegant solution perhaps, but it works...

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  2. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  3. Codec Bitrates?
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 06-16-2003, 08:39 AM
  4. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 02:58 AM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM