2 #define DEBUG_VS // Uncomment this line to debug vertex shaders 3 #define DEBUG_PS // Uncomment this line to debug pixel shaders 17 INT WINAPI
WinMain(HINSTANCE, HINSTANCE, LPSTR,
int)
21 #define _CRTDBG_MAPALLOC 49 DXUTSetCursorSettings(
true,
true);
50 DXUTSetHotkeyHandling(
false,
false,
false);
51 DXUTSetConstantFrameTime(
false);
56 DXUTInit(
false,
false,
nullptr,
false,
true);
59 if (!GetWindowRect(GetDesktopWindow(), &desktop))
62 sprintf_s(msg, 99,
"Error in GetWindowRect: %d", GetLastError());
67 const HDC hDC = GetDC(
nullptr);
68 const int nLogPixelsY = GetDeviceCaps(hDC, LOGPIXELSY);
69 ReleaseDC(
nullptr, hDC);
70 gPtr->
dpiscale =
static_cast<float>(nLogPixelsY) / 96.0f;
72 gPtr->
displayWidth =
static_cast<float>(desktop.right - desktop.left);
73 gPtr->
displayHeight =
static_cast<float>(desktop.bottom - desktop.top);
86 sprintf_s(msg, 99,
"config initial scale %.1f (dpiscale %.1f)", gPtr->
config.
scale, gPtr->
dpiscale);
87 gPtr->
logger->
Log(msg, Logger::Level::Debug);
89 else if (gPtr->
config.
scale > min(xScale, yScale) * 1.5f)
92 sprintf_s(msg, 99,
"config adjust scale was %.1f xScale %.1f yScale %.1f (min %.1f): %.1f", gPtr->
config.
scale, xScale, yScale, min(xScale, yScale), min(xScale, yScale) * 1.5f);
93 gPtr->
logger->
Log(msg, Logger::Level::Debug);
100 sprintf_s(msg, 99,
"config adjust scale was %.1f xScale %.1f yScale %.1f (min %.1f): %.1f", gPtr->
config.
scale, xScale, yScale, min(xScale, yScale), max(1, 0.5f * gPtr->
dpiscale));
101 gPtr->
logger->
Log(msg, Logger::Level::Debug);
109 if (FAILED(DXUTCreateDevice(
true, static_cast<int>(700 * gPtr->
displayscale), static_cast<int>(500 * gPtr->
displayscale))))
111 gPtr->
logger->
Log(
"Could not DXUTCreateDevice() instance...", Logger::Level::Fatal);
115 if (!SetWindowText(DXUTGetHWND(), L
"Rise: The Vieneo Province"))
118 sprintf_s(msg, 99,
"Error in SetWindowText: %d", GetLastError());
126 gPtr->
logger->
Log(
"Could not InitDirectInput() instance...", Logger::Level::Fatal);
139 if (DXUTGetExitCode() != 0)
140 gPtr->
logger->
Log(DXUTGetErrorMessage(), Logger::Level::Fatal);
142 catch (std::exception& e)
145 sprintf_s(msg, 199,
"std::exception '%s'", e.what());
146 gPtr->
logger->
Log(msg, Logger::Level::Fatal);
151 sprintf_s(msg, 199,
"char* '%s'", e);
152 gPtr->
logger->
Log(msg, Logger::Level::Fatal);
154 catch (std::string& e)
157 sprintf_s(msg, 199,
"std::string '%s'", e.c_str());
158 gPtr->
logger->
Log(msg, Logger::Level::Fatal);
162 gPtr->
logger->
Log(
"Untyped exception occurred", Logger::Level::Fatal);
170 DXUTSetCallbackMsgProc(
nullptr,
nullptr);
171 DXUTSetCallbackD3D9DeviceCreated(
nullptr,
nullptr);
172 DXUTSetCallbackD3D9DeviceReset(
nullptr,
nullptr);
173 DXUTSetCallbackD3D9DeviceLost(
nullptr,
nullptr);
174 DXUTSetCallbackD3D9DeviceDestroyed(
nullptr,
nullptr);
175 DXUTSetCallbackMsgProc(
nullptr,
nullptr);
176 DXUTSetCallbackKeyboard(
nullptr,
nullptr);
177 DXUTSetCallbackD3D9FrameRender(
nullptr,
nullptr);
178 DXUTSetCallbackFrameMove(
nullptr,
nullptr);
179 DXUTSetCallbackD3D9DeviceAcceptable(
nullptr,
nullptr);
180 DXUTSetCallbackDeviceChanging(
nullptr,
nullptr);
185 return DXUTGetExitCode();
static void CALLBACK OnLostDevice(void *pUserContext)
static void CALLBACK KeyboardProc(UINT nChar, bool bKeyDown, bool bAltDown, void *pUserContext)
static void CALLBACK OnDestroyDevice(void *pUserContext)
static LRESULT CALLBACK MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool *pbNoFurtherProcessing, void *pUserContext)
static HRESULT CALLBACK OnResetDevice(IDirect3DDevice9 *pd3dDevice, const D3DSURFACE_DESC *pBackBufferSurfaceDesc, void *pUserContext)
static void CALLBACK OnFrameRender(IDirect3DDevice9 *pd3dDevice, double fTime, float fElapsedTime, void *pUserContext)
static HRESULT CALLBACK OnCreateDevice(IDirect3DDevice9 *pd3dDevice, const D3DSURFACE_DESC *pBackBufferSurfaceDesc, void *pUserContext)
INT WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
static bool CALLBACK IsDeviceAcceptable(D3DCAPS9 *pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void *pUserContext)
HRESULT InitDirectInput(HWND hDlg) const
void Log(const char *msg, Level level=Info, int errorCode=0)
static void CALLBACK OnFrameMove(double fTime, float fElapsedTime, void *pUserContext)
void AddToCallStack(const char *msg)
static bool CALLBACK ModifyDeviceSettings(DXUTDeviceSettings *pDeviceSettings, void *pUserContext)