Problems useing swapchains

Started by
2 comments, last by Roziks_World 15 years, 5 months ago
Hi everyone, i am trying to render into 4 different Windows useing swapchains but somehow its not working:-( Maybe someone could look at my code and tell me if i am doing something obvious wrong. Creating the Windows: hWnd3D = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("static"), NULL, WS_CHILD | SS_BLACKRECT | WS_VISIBLE, x, y, rcWnd.right/2-20, rcWnd.bottom/2-20, g_hWnd, NULL, g_hInst, NULL); Creating the swap chains: m_d3dpp.hDeviceWindow = m_hWnd; m_pDevice->CreateAdditionalSwapChain(&m_d3dpp, &m_pChain); Picking a window to render to: HRESULT FBSDeviceD3D::useWindow(UINT nHwnd){ LPDIRECT3DSURFACE9 pBack = NULL; if(!m_d3dpp.Windowed){ return FBS_OK; } else if(nHwnd >= m_nNumWnd) return FBS_FAIL; //try to get the appropriate back buffer if(FAILED(m_pChain[nHwnd]->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pBack))) return FBS_FAIL; //actuave the back buffer for the device m_pDevice->SetRenderTarget(0, pBack); pBack->Release(); m_nActivehWnd = nHwnd; return FBS_OK; } Thx a lot in advance for any hints you guy smight have.
Advertisement
Quote:Original post by Roziks_World
Hi everyone,

i am trying to render into 4 different Windows useing swapchains but somehow its not working:-(
Define "not working". Does it crash? Does it render nothing? Any output from the Debug Runtimes?
Well if i dont use the "useWindow" function at all it renders into the first window.

If i use the useWindow function to set the render window i get 4 black windows and nothing is rendered even when i set it to the first window.

Its not crashing its just not rendering anything.

Here is my Post Render function:

indBool FBSDeviceD3D::postRender(){
m_pDevice->EndScene();
m_pDevice->Present(NULL, NULL, NULL, NULL);
m_bIsSceneRunning = false;
return true;
}//postRender
Nevermind :-)

Just found the problem :-)

Changed my postRender function to this:

indBool FBSDeviceD3D::postRender(){
m_pDevice->EndScene();

if (m_pEnum->m_Windowed && ( m_nNumWnd > 0) ) {
if (FAILED(m_pChain[m_nActivehWnd]->Present(NULL, NULL, NULL, NULL, 0)))
FBSLogger::Instance()->log("FBSDeviceD3D", "error: Chain->Present() from EndRendering() failed", FBSLogger::Instance()->LOG_ERROR);
}
else {
if (FAILED(m_pDevice->Present(NULL, NULL, NULL, NULL)))
FBSLogger::Instance()->log("FBSDeviceD3D", "error: Deviec->Present() from EndRendering() failed", FBSLogger::Instance()->LOG_ERROR);
}

m_bIsSceneRunning = false;
return true;
}//postRender

This topic is closed to new replies.

Advertisement