int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(nCmdShow); UNREFERENCED_PARAMETER(pCmdLine); //notify user if heap is corrupt HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL,0); // Enable run-time memory leak check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); typedef HRESULT(__stdcall *fPtr)(const IID&, void**); HMODULE hDll = LoadLibrary(L"dxgidebug.dll"); fPtr DXGIGetDebugInterface = (fPtr)GetProcAddress(hDll, "DXGIGetDebugInterface"); IDXGIDebug* pDXGIDebug; DXGIGetDebugInterface(__uuidof(IDXGIDebug), (void**)&pDXGIDebug); //_CrtSetBreakAlloc(4039); #endif auto pGame = new MainGame(); auto result = pGame->Run(hInstance); UNREFERENCED_PARAMETER(result); delete pGame; return 0; }
void XApp::destroy() { // Wait for the GPU to be done with all resources. //WaitForGpu(); app->destroy(); //Sleep(150); //CloseHandle(fenceEvent); #ifdef _DEBUG //ThrowIfFailed(DXGIGetDebugInterface1(0, )); typedef HRESULT(__stdcall *fPtr)(const IID&, void**); HMODULE hDll = GetModuleHandleW(L"dxgidebug.dll"); fPtr DXGIGetDebugInterface = (fPtr)GetProcAddress(hDll, "DXGIGetDebugInterface"); IDXGIDebug *pDxgiDebug; DXGIGetDebugInterface(__uuidof(IDXGIDebug), (void**)&pDxgiDebug); //pDxgiDebug->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL); #endif }
void DesktopApp::Run() { // ------------- init Engine objects Assert(!Engine::instance().isInit()); Engine::instance().initLowLevel(); try { // ------------- call main class init() m_mainClass->init(); m_frameDurationCounter.init(); while (Engine::instance().isRunning() && !reinterpret_cast<const DesktopWindow*>(getWindow())->mustBeDestroyed()) // ------------ MAIN LOOP { // ------------ manage events this->manageEvents(); if (!m_suspended) { // ------------- call main class update() bool needProcessAgain = m_mainClass->update(); if (reinterpret_cast<const DesktopWindow*>(getWindow())->mustBeDestroyed() || !Engine::instance().isRunning()) break; Engine::instance().updateInternals(); // ------------ call main class render() this->BeginDraw(); m_mainClass->render(); this->EndDraw(); } Engine::instance().m_frameDuration = m_frameDurationCounter.retrieve(); } m_mainClass->deinit(); Engine::instance().deinitLowLevel(); } catch (EngineError e) { outputln("Caught EngineError"); if (this->isDrawing()) this->EndDraw(); m_isCrashedState = true; while (true) { this->manageEvents(); Engine::instance().updateInternals(); this->BeginDraw(); Engine::instance().clearScreen(CoreUtils::colorBlack); Engine::instance().getScene2DMgr().drawText(NULL, Utils::convertWStringToString(e.getFullText(), false).c_str(), Int2(20, 40), 18, CoreUtils::colorWhite); this->EndDraw(); Engine::instance().m_frameDuration = m_frameDurationCounter.retrieve(); } } cleanup(); uninitializeWindow(); outputln("======== CLEANUP DONE ========"); #ifndef NDEBUG // http://gamedev.stackexchange.com/questions/14633/what-do-these-state-creation-warnings-mean-in-the-dx11-debug-output typedef HRESULT(__stdcall *fPtr)(const IID&, void**); HMODULE hDll = GetModuleHandleW(L"dxgidebug.dll"); fPtr DXGIGetDebugInterface = (fPtr)GetProcAddress(hDll, "DXGIGetDebugInterface"); IDXGIDebug* pDxgiDebug; DXGIGetDebugInterface(__uuidof(IDXGIDebug), (void**)&pDxgiDebug); pDxgiDebug->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL); #endif }