10 __try {
return window.
Run(); }
13 TerminateProcess(GetCurrentProcess(), GetExceptionCode());
return EXIT_FAILURE;
18 __try {
return GameClass::MsgProc(window, message, wParam, lParam, handled, context); }
21 TerminateProcess(GetCurrentProcess(), GetExceptionCode());
return 0;
26 const HRESULT comResult = CoInitializeEx(
nullptr, COINIT_APARTMENTTHREADED);
27 if (FAILED(comResult) && comResult != RPC_E_CHANGED_MODE)
return EXIT_FAILURE;
28 struct ComLifetime {
bool initialized; ~ComLifetime() {
if (initialized)CoUninitialize(); } } com{ SUCCEEDED(comResult) };
32 struct RuntimeLifetime
46 if (!GetWindowRect(GetDesktopWindow(), &desktop))
49 sprintf_s(msg,
sizeof msg,
"Error in GetWindowRect: %d", GetLastError());
54 const HDC hDC = GetDC(
nullptr);
55 const int nLogPixelsY = GetDeviceCaps(hDC, LOGPIXELSY);
56 ReleaseDC(
nullptr, hDC);
57 gPtr->
dpiscale =
static_cast<float>(nLogPixelsY) / 96.0f;
59 gPtr->
displayWidth =
static_cast<float>(desktop.right - desktop.left);
60 gPtr->
displayHeight =
static_cast<float>(desktop.bottom - desktop.top);
73 sprintf_s(msg,
sizeof msg,
"config initial scale %.1f (dpiscale %.1f)", gPtr->
config.
scale, gPtr->
dpiscale);
79 sprintf_s(msg,
sizeof msg,
"config adjust scale was %.1f xScale %.1f yScale %.1f (min %.1f): %.1f", gPtr->
config.
scale, xScale, yScale,
RiseMath::Min(xScale, yScale),
RiseMath::Min(xScale, yScale) * 1.5f);
106 options.
debugLayer = wcsstr(GetCommandLineW(), L
"--d3d11-debug") !=
nullptr;
107 options.
warp = wcsstr(GetCommandLineW(), L
"--warp") !=
nullptr;
117 callbacks.
message = [&](HWND handle, UINT message, WPARAM wParam, LPARAM lParam,
bool& handled)
119 callbacks.
report = [&](
const std::string& status,
HRESULT result)
127 int result = EXIT_FAILURE;
133INT WINAPI
WinMain(HINSTANCE, HINSTANCE, LPSTR,
int)
138 TerminateProcess(GetCurrentProcess(), GetExceptionCode());
return EXIT_FAILURE;
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
static int RunMainLoopWithCrashDiagnostics(Rendering::Window11 &window)
INT WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
static LRESULT MsgProcWithCrashDiagnostics(HWND window, UINT message, WPARAM wParam, LPARAM lParam, bool *handled, void *context)
unsigned char videoSamples
static HRESULT CALLBACK OnResetDevice(Rendering::RenderDevice *pd3dDevice, const Rendering::SurfaceDescription *pBackBufferSurfaceDesc, void *pUserContext)
static void CALLBACK OnDestroyDevice(void *pUserContext)
HRESULT InitDirectInput(HWND hDlg) const
static void CALLBACK KeyboardProc(UINT nChar, bool bKeyDown, bool bAltDown, void *pUserContext)
static void CALLBACK OnLostDevice(void *pUserContext)
static void CALLBACK OnFrameMove(double fTime, float fElapsedTime, void *pUserContext)
static void CALLBACK OnFrameRender(Rendering::RenderDevice *pd3dDevice, double fTime, float fElapsedTime, void *pUserContext)
HRESULT OnFramePresented()
static LRESULT CALLBACK MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool *pbNoFurtherProcessing, void *pUserContext)
std::unique_ptr< Logger > logger
static HRESULT CALLBACK OnCreateDevice(Rendering::RenderDevice *pd3dDevice, const Rendering::SurfaceDescription *pBackBufferSurfaceDesc, void *pUserContext)
void Log(const char *msg, Level level=Info, int errorCode=0)
static long __stdcall HandleNativeException(struct _EXCEPTION_POINTERS *exception)
void StopCallbacksAndWindow()
HRESULT Create(const WindowOptions11 &options, Callbacks callbacks)
renderer(Viewscreen *ptr)
void AttachClientRuntime(Window11 *window, RenderDevice *device)
const SurfaceDescription * ClientBackBufferDescription()
constexpr auto Min(A first, B second)
constexpr auto Max(A first, B second)
std::function< HRESULT(UINT, UINT)> resize
std::function< void()> destroy
std::function< void(double, float)> move
std::function< LRESULT(HWND, UINT, WPARAM, LPARAM, bool &)> message
std::function< HRESULT()> presented
std::function< void(const std::string &, HRESULT)> report
std::function< HRESULT()> create
std::function< void(UINT, bool, bool)> keyboard
std::function< void()> releaseSizeDependent
std::function< HRESULT(double, float)> draw