bool CD3D_Device::DestroyRenderObject(CRenderObject* pObject) { if (pObject == g_Device.m_pRenderObjectList_Head) { // Remove the sucka from the Render Object List... g_Device.m_pRenderObjectList_Head = pObject->GetNext(); } else { CRenderObject* pPrevObject = g_Device.m_pRenderObjectList_Head; while (pPrevObject->GetNext() && pPrevObject->GetNext() != pObject) { pPrevObject = pPrevObject->GetNext(); } if (pPrevObject->GetNext()) { pPrevObject->SetNext(pPrevObject->GetNext()->GetNext()); } else { assert(0); return false; } } // It's not in the list!?! delete pObject; // Ok, now delete the sucka... return true; }
// If device we lost, restores the objects (calls ReCreateObject on all the Render Objects)... bool CD3D_Device::RestoreDevObjects() { // Notify all RenderObjects that they need to re-create themselves... CRenderObject* pRenderObject = m_pRenderObjectList_Head; while (pRenderObject) { pRenderObject->ReCreateObject(); pRenderObject = pRenderObject->GetNext(); } return true; }
// Release all the device objects (the Render Objects)... bool CD3D_Device::ReleaseDevObjects() { // Notify all RenderObjects that we're going to free the device (to give up all there device stuff) CRenderObject* pRenderObject = m_pRenderObjectList_Head; while (pRenderObject) { pRenderObject->FreeDeviceObjects(); pRenderObject = pRenderObject->GetNext(); } return true; }
bool CD3D_Device::DestroyRenderObject(CRenderObject* pObject) { if (pObject == g_Device.m_pRenderObjectList_Head) { // Remove the sucka from the Render Object List... g_Device.m_pRenderObjectList_Head = pObject->GetNext(); } else { if (!g_Device.m_pRenderObjectList_Head) { // It's not in the list!?! //assert(0); // Note : This really should assert, but this happens VERY frequently and doesn't seem to be causing any problems return false; } CRenderObject* pPrevObject = g_Device.m_pRenderObjectList_Head; while (pPrevObject->GetNext() && pPrevObject->GetNext() != pObject) { pPrevObject = pPrevObject->GetNext(); } if (pPrevObject->GetNext()) { pPrevObject->SetNext(pPrevObject->GetNext()->GetNext()); } else { // It's not in the list!?! assert(0); return false; } } delete pObject; // Ok, now delete the sucka... return true; }
// If device we lost, restores the objects (calls ReCreateObject on all the Render Objects)... bool CD3D_Device::RestoreDevObjects() { LTVertexShaderMgr::GetSingleton().RecreateVertexShaders(); LTPixelShaderMgr::GetSingleton().RecreatePixelShaders(); LTEffectShaderMgr::GetSingleton().RecreateEffectShaders(); CRenderTargetMgr::GetSingleton().RecreateRenderTargets(); // Notify all RenderObjects that they need to re-create themselves... CRenderObject* pRenderObject = m_pRenderObjectList_Head; while (pRenderObject) { pRenderObject->ReCreateObject(); pRenderObject = pRenderObject->GetNext(); } return true; }
// Release all the device objects (the Render Objects)... bool CD3D_Device::ReleaseDevObjects(bool bFullRelease) { //free the screen glow's resources CScreenGlowMgr::GetSingleton().FreeDeviceObjects(); // free the vertex shaders LTVertexShaderMgr::GetSingleton().FreeDeviceObjects(); // Free the pixel shaders. LTPixelShaderMgr::GetSingleton().FreeDeviceObjects(); // Free the effect shaders. LTEffectShaderMgr::GetSingleton().FreeDeviceObjects(); // Free the rendertarget textures and surfaces CRenderTargetMgr::GetSingleton().FreeDeviceObjects(); // Notify all RenderObjects that we're going to free the device (to give up all there device stuff) CRenderObject* pRenderObject = m_pRenderObjectList_Head; while (pRenderObject) { pRenderObject->FreeDeviceObjects(); pRenderObject = pRenderObject->GetNext(); } if (m_pRenderWorld) m_pRenderWorld->Release(); if( m_pEndOfFrameQuery ) { m_pEndOfFrameQuery->Release(); m_pEndOfFrameQuery = NULL; } FreeFrameTextures(); // Don't actually delete them unless we really want to if (bFullRelease) { delete m_pRenderWorld; m_pRenderWorld = 0; } return true; }