void App::Shutdown_Internal() { DX12::FlushGPU(); DestroyPSOs(); ImGuiHelper::Shutdown(); ShutdownShaders(); spriteRenderer.Shutdown(); font.Shutdown(); swapChain.Shutdown(); AppSettings::Shutdown(); Profiler::GlobalProfiler.Shutdown(); Shutdown(); DX12::Shutdown(); }
int32 App::Run() { try { if(createConsole) { Win32Call(AllocConsole()); Win32Call(SetConsoleTitle(applicationName.c_str())); FILE* consoleFile = nullptr; freopen_s(&consoleFile, "CONOUT$", "wb", stdout); } window.SetClientArea(deviceManager.BackBufferWidth(), deviceManager.BackBufferHeight()); deviceManager.Initialize(window); if(showWindow) window.ShowWindow(); blendStates.Initialize(deviceManager.Device()); rasterizerStates.Initialize(deviceManager.Device()); depthStencilStates.Initialize(deviceManager.Device()); samplerStates.Initialize(deviceManager.Device()); // Create a font + SpriteRenderer font.Initialize(L"Arial", 18, SpriteFont::Regular, true, deviceManager.Device()); spriteRenderer.Initialize(deviceManager.Device()); Profiler::GlobalProfiler.Initialize(deviceManager.Device(), deviceManager.ImmediateContext()); window.RegisterMessageCallback(WM_SIZE, OnWindowResized, this); // Initialize AntTweakBar TwCall(TwInit(TW_DIRECT3D11, deviceManager.Device())); // Create a tweak bar tweakBar = TwNewBar("Settings"); std::string helpTextDefinition = MakeAnsiString(" GLOBAL help='%s' ", globalHelpText.c_str()); TwCall(TwDefine(helpTextDefinition.c_str())); TwCall(TwDefine(" GLOBAL fontsize=3 ")); Settings.Initialize(tweakBar); TwHelper::SetValuesWidth(Settings.TweakBar(), 120, false); AppSettings::Initialize(deviceManager.Device()); Initialize(); AfterReset(); while(window.IsAlive()) { if(!window.IsMinimized()) { timer.Update(); Settings.Update(); CalculateFPS(); AppSettings::Update(); Update(timer); UpdateShaders(deviceManager.Device()); AppSettings::UpdateCBuffer(deviceManager.ImmediateContext()); Render(timer); // Render the profiler text spriteRenderer.Begin(deviceManager.ImmediateContext(), SpriteRenderer::Point); Profiler::GlobalProfiler.EndFrame(spriteRenderer, font); spriteRenderer.End(); { PIXEvent pixEvent(L"Ant Tweak Bar"); // Render the TweakBar UI TwCall(TwDraw()); } deviceManager.Present(); } window.MessageLoop(); } } catch(SampleFramework11::Exception exception) { exception.ShowErrorMessage(); return -1; } ShutdownShaders(); TwCall(TwTerminate()); if(createConsole) { fclose(stdout); FreeConsole(); } return returnCode; }
void ColorShader::Shutdown() { ShutdownShaders(); }