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:
Code:
void CEditor3D::Render(float fTimeDelta)
{
//Render main view using D3DPRESENT_PARAMETERS
m_pDevice->Clear(0,0,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,0,1.0f,0);
m_pDevice->BeginScene();
....
m_pDevice->EndScene();
m_pDevice->Present(0,0,0,0);
//Render all windows
LPDIRECT3DSURFACE9 pBackBuffer=NULL;
for (unsigned int i=0;i<m_vWindowList.size();i++)
{
m_vWindowList[i]->m_pSwapChain->GetBackBuffer(0,D3DBACKBUFFERTYPE_MONO,&pBackBuffer);
m_pDevice->SetRenderTarget(0,pBackBuffer);
m_pDevice->Clear(0,0,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,0,1.0f,0);
m_pDevice->BeginScene();
...
m_vWindowList[i]->Render(fTimeDelta);
...
m_pDevice->EndScene();
m_vWindowList[i]->m_pSwapChain->Present(0,0,m_vWindowList[i].m_hwnd,0,0);
pBackBuffer->Release();
}
}
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.