// Call the user's Render() callback (if it exists) //----------------------------------------------------------------------------- void CPUT_DX11::InnerExecutionLoop() { #ifdef CPUT_GPA_INSTRUMENTATION D3DPERF_BeginEvent(D3DCOLOR(0xff0000), L"CPUT User's Render() "); #endif if(!mbShutdown) { double deltaSeconds = mpTimer->GetElapsedTime(); Update(deltaSeconds); Present(); // Note: Presenting immediately before Rendering minimizes CPU stalls (i.e., execute Update() before Present() stalls) double totalSeconds = mpTimer->GetTotalTime(); UpdatePerFrameConstantBuffer(totalSeconds); CPUTMaterialDX11::ResetStateTracking(); Render(deltaSeconds); if(!CPUTOSServices::GetOSServices()->DoesWindowHaveFocus()) { Sleep(100); } } else { #ifndef _DEBUG exit(0); #endif Present(); // Need to present, or will leak all references held by previous Render()! ShutdownAndDestroy(); } #ifdef CPUT_GPA_INSTRUMENTATION D3DPERF_EndEvent(); #endif }
// Window is closing. Shut the system to shut down now, not later. //----------------------------------------------------------------------------- void CPUT_DX11::DeviceShutdown() { if(false == mbShutdown) { mbShutdown = true; ShutdownAndDestroy(); } }
// Window is closing. Shut the system to shut down now, not later. //----------------------------------------------------------------------------- void CPUT_DX11::DeviceShutdown() { if(mpSwapChain) { // DX requires setting fullscreenstate to false before exit. mpSwapChain->SetFullscreenState(false, NULL); } if(false == mbShutdown) { mbShutdown = true; ShutdownAndDestroy(); } }