Select Git revision
Engine.cpp 18.09 KiB
#include "Engine.h"
#include <core/task.h>
#include <GRegisterIndex.h>
#include <core/taskmanager.h>
#include "SkyXEngine.h"
#include <xcommon/IXSoundSystem.h>
#ifdef _DEBUG
# pragma comment(lib, "sxcore_d.lib")
#else
# pragma comment(lib, "sxcore.lib")
#endif
#ifdef USE_BREAKPAD
# pragma comment(lib, "crash_generation_client.lib")
# pragma comment(lib, "exception_handler.lib")
# pragma comment(lib, "common.lib")
#endif
class CMainLoopTask: public ITaskImpl<ITask>
{
public:
CMainLoopTask(CEngine *pEngine):
m_pEngine(pEngine),
ITaskImpl(CORE_TASK_FLAG_MAINTHREAD_REPEATING)
{
}
void run() override
{
if(!m_pEngine->runFrame())
{
XCoreStop();
}
}
protected:
CEngine *m_pEngine;
};
//##########################################################################
#ifdef USE_BREAKPAD
static bool HandleCrashDump(const wchar_t *wszDumpPath, const wchar_t* wszMinidumpId, void* pContext, EXCEPTION_POINTERS* pExInfo, MDRawAssertionInfo* pAssertion, bool isSucceeded)
{
wchar_t *pCrashReporter = (wchar_t*)pContext;
if(isSucceeded)
{
wcscat(pCrashReporter, wszMinidumpId);
STARTUPINFOW info = {sizeof(info)};
PROCESS_INFORMATION processInfo;
if(CreateProcessW(NULL, pCrashReporter, NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo))
{
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
}
else
{
MessageBoxW(NULL, L"Program has crashed. Failed to write crashdump.", L"Crashed!", MB_OK | MB_ICONSTOP);
}
//MessageBoxW(NULL, wszMinidumpId, pCrashReporter, MB_OK | MB_ICONSTOP);
return(true);
}
#endif
//##########################################################################