From e1d6dc27ec013dfecde942c7690432925ce3e23a Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 13 Dec 2018 23:28:05 -0800 Subject: Fixed MinGW build --- Common/NativeApp/src/Win32/WinMain.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'Common/NativeApp/src/Win32/WinMain.cpp') diff --git a/Common/NativeApp/src/Win32/WinMain.cpp b/Common/NativeApp/src/Win32/WinMain.cpp index 24777b5..62e8f40 100644 --- a/Common/NativeApp/src/Win32/WinMain.cpp +++ b/Common/NativeApp/src/Win32/WinMain.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "NativeAppBase.h" #include "StringTools.h" #include "Timer.h" @@ -40,14 +41,20 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int cmdShow) g_pTheApp.reset( CreateApplication() ); - const auto *cmdLine = GetCommandLineA(); + const auto* cmdLine = GetCommandLineA(); g_pTheApp->ProcessCommandLine(cmdLine); - std::wstring Title = Diligent::WidenString(g_pTheApp->GetAppTitle()); + const auto* AppTitle = g_pTheApp->GetAppTitle(); + +#ifdef UNICODE + const auto* const WindowClassName = L"SampleApp"; +#else + const auto* const WindowClassName = "SampleApp"; +#endif // Register our window class WNDCLASSEX wcex = { sizeof(WNDCLASSEX), CS_HREDRAW|CS_VREDRAW, MessageProc, - 0L, 0L, instance, NULL, NULL, NULL, NULL, L"SampleApp", NULL }; + 0L, 0L, instance, NULL, NULL, NULL, NULL, WindowClassName, NULL }; RegisterClassEx(&wcex); // Create a window @@ -55,12 +62,12 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int cmdShow) LONG WindowHeight = 1024; RECT rc = { 0, 0, WindowWidth, WindowHeight }; AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE); - HWND wnd = CreateWindow(L"SampleApp", Title.c_str(), + HWND wnd = CreateWindowA("SampleApp", AppTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rc.right-rc.left, rc.bottom-rc.top, NULL, NULL, instance, NULL); if (!wnd) { - MessageBox(NULL, L"Cannot create window", L"Error", MB_OK|MB_ICONERROR); + MessageBoxA(NULL, "Cannot create window", "Error", MB_OK|MB_ICONERROR); return 0; } ShowWindow(wnd, cmdShow); @@ -94,10 +101,10 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int cmdShow) double filterScale = 0.2; filteredFrameTime = filteredFrameTime * (1.0 - filterScale) + filterScale * ElapsedTime; - std::wstringstream fpsCounterSS; - fpsCounterSS << " - " << std::fixed << std::setprecision(1) << filteredFrameTime * 1000; + std::stringstream fpsCounterSS; + fpsCounterSS << AppTitle << " - " << std::fixed << std::setprecision(1) << filteredFrameTime * 1000; fpsCounterSS << " ms (" << 1.0 / filteredFrameTime << " fps)"; - SetWindowText(wnd, (Title + fpsCounterSS.str()).c_str()); + SetWindowTextA(wnd, fpsCounterSS.str().c_str()); } } -- cgit v1.2.3