//-------------------------------------------------------------------------------------- // //-------------------------------------------------------------------------------------- void CreateRenderTargets(ID3D11Device* pd3dDevice) { ReleaseRenderTargets(); D3D11_TEXTURE2D_DESC texDesc; texDesc.Width = g_BackBufferWidth; texDesc.Height = g_BackBufferHeight; texDesc.ArraySize = 1; texDesc.MiscFlags = 0; texDesc.MipLevels = 1; texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; texDesc.Usage = D3D11_USAGE_DEFAULT; texDesc.CPUAccessFlags = NULL; // Allocate MSAA color buffer texDesc.SampleDesc.Count = g_MSAADesc[g_MSAACurrentSettings].SampleCount; texDesc.SampleDesc.Quality = 0; texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; pd3dDevice->CreateTexture2D(&texDesc, NULL, &g_ColorTexture); pd3dDevice->CreateRenderTargetView(g_ColorTexture, NULL, &g_ColorRTV); pd3dDevice->CreateShaderResourceView(g_ColorTexture, NULL, &g_ColorSRV); // Allocate MSAA normal buffer texDesc.Format = DXGI_FORMAT_R11G11B10_FLOAT; pd3dDevice->CreateTexture2D(&texDesc, NULL, &g_NormalTexture); pd3dDevice->CreateRenderTargetView(g_NormalTexture, NULL, &g_NormalRTV); pd3dDevice->CreateShaderResourceView(g_NormalTexture, NULL, &g_NormalSRV); }
void UIScreenTransition::Update(float32 timeElapsed) { currentTime += timeElapsed; normalizedTime = interpolationFunc(currentTime / duration); if (currentTime >= duration) { currentTime = duration; nextScreen->SystemDidAppear(); ReleaseRenderTargets(); // go to next screen UIControlSystem::Instance()->ReplaceScreen(nextScreen); UIControlSystem::Instance()->UnlockInput(); /* Right now we are in update so when we change control we miss Update for new screen Here we call update control to make calls to update / draw sequential and avoid problem with missing Update We pass current timeElapsed because we miss current frame time */ nextScreen->SystemUpdate(timeElapsed); // } }
//-------------------------------------------------------------------------------------- // This callback function will be called immediately after the Direct3D device has // been destroyed, which generally happens as a result of application termination or // windowed/full screen toggles. //-------------------------------------------------------------------------------------- void CALLBACK OnD3D11DestroyDevice(void* pUserContext) { DXUTTRACE(L"OnD3D11DestroyDevice called\n"); g_DialogResourceManager.OnD3D11DestroyDevice(); g_SettingsDlg.OnD3D11DestroyDevice(); DXUTGetGlobalResourceCache().OnDestroyDevice(); SAFE_DELETE(g_pTxtHelper); g_pSceneRenderer.OnDestroyDevice(); for (int i = 0; i < ARRAYSIZE(g_MeshDesc); i++) { g_SceneMeshes[i].OnDestroyDevice(); } ReleaseRenderTargets(); ReleaseDepthBuffer(); g_AORenderer.Release(); }
void Term() { // Don't over-term if (!m_nRefCount) return; // Only truly terminate when the last volumetric light goes away --m_nRefCount; if (m_nRefCount) return; // Let go of the vertex decl if (m_hVertexDecl) g_pLTCustomRender->ReleaseVertexDeclaration(m_hVertexDecl); m_hVertexDecl = NULL; // Let go of our materials for (uint32 nLoop = 0; nLoop < LTARRAYSIZE(m_aSliceMaterials); ++nLoop) { if (m_aSliceMaterials[nLoop]) g_pLTRenderer->ReleaseMaterialInstance(m_aSliceMaterials[nLoop]); m_aSliceMaterials[nLoop] = NULL; } if (m_hShellMaterial) g_pLTRenderer->ReleaseMaterialInstance(m_hShellMaterial); m_hShellMaterial = NULL; // Let go of the shell IB if (m_hShellIB) g_pLTCustomRender->ReleaseIndexBuffer(m_hShellIB); m_hShellIB = NULL; // Let go of the render targets ReleaseRenderTargets(); // Let go of the game database category DATABASE_CATEGORY(VolumetricLight).Term(); }