From cc1ff26c3f078cd11f309a7cb24b7921baef89b7 Mon Sep 17 00:00:00 2001 From: adrido Date: Thu, 30 Mar 2017 20:28:37 +0200 Subject: Windows: Set window icon (#5486) --- src/porting.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/porting.cpp') diff --git a/src/porting.cpp b/src/porting.cpp index 023f0cca7..4786a2a39 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -611,9 +611,9 @@ void setXorgClassHint(const video::SExposedVideoData &video_data, #endif } -bool setXorgWindowIcon(IrrlichtDevice *device) +bool setWindowIcon(IrrlichtDevice *device) { -#ifdef XORG_USED +#if defined(XORG_USED) # if RUN_IN_PLACE return setXorgWindowIconFromPath(device, path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png"); @@ -627,6 +627,36 @@ bool setXorgWindowIcon(IrrlichtDevice *device) setXorgWindowIconFromPath(device, path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png"); # endif +#elif defined(_WIN32) + const video::SExposedVideoData exposedData = device->getVideoDriver()->getExposedVideoData(); + HWND hWnd; // Window handle + + switch (device->getVideoDriver()->getDriverType()) { + case video::EDT_DIRECT3D8: + hWnd = reinterpret_cast(exposedData.D3D8.HWnd); + break; + case video::EDT_DIRECT3D9: + hWnd = reinterpret_cast(exposedData.D3D9.HWnd); + break; + case video::EDT_OPENGL: + hWnd = reinterpret_cast(exposedData.OpenGLWin32.HWnd); + break; + default: + return false; + } + + // Load the ICON from resource file + const HICON hicon = LoadIcon( + GetModuleHandle(NULL), + MAKEINTRESOURCE(130) // The ID of the ICON defined in winresource.rc + ); + + if (hicon) { + SendMessage(hWnd, WM_SETICON, ICON_BIG, reinterpret_cast(hicon)); + SendMessage(hWnd, WM_SETICON, ICON_SMALL, reinterpret_cast(hicon)); + return true; + } + return false; #else return false; #endif -- cgit v1.2.3 From 676951d90dc7807733288c3c66952bb0394e2e7c Mon Sep 17 00:00:00 2001 From: adrido Date: Fri, 7 Apr 2017 07:14:39 +0200 Subject: Windows: Skip cmd for release builds (#5416) --- src/porting.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/porting.cpp') diff --git a/src/porting.cpp b/src/porting.cpp index 4786a2a39..9d859da7d 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -929,4 +929,18 @@ bool secure_rand_fill_buf(void *buf, size_t len) #endif +void attachOrCreateConsole(void) +{ +#ifdef _WIN32 + static bool consoleAllocated = false; + const bool redirected = (_fileno(stdout) == -2 || _fileno(stdout) == -1); // If output is redirected to e.g a file + if (!consoleAllocated && redirected && (AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole())) { + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + consoleAllocated = true; + } +#endif +} + + } //namespace porting -- cgit v1.2.3 From f98bbe193e0093aca8d8957cec82fdbd28639915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Thu, 20 Apr 2017 00:12:52 +0200 Subject: Fix various copy instead of const ref reported by cppcheck (part 3) (#5616) * Also remove 2 non declared but defined functions * Make some functions around const ref changes const --- src/porting.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/porting.cpp') diff --git a/src/porting.cpp b/src/porting.cpp index 9d859da7d..8c92a3cba 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -408,7 +408,7 @@ bool setSystemPaths() #endif for (std::list::const_iterator - i = trylist.begin(); i != trylist.end(); i++) { + i = trylist.begin(); i != trylist.end(); ++i) { const std::string &trypath = *i; if (!fs::PathExists(trypath) || !fs::PathExists(trypath + DIR_DELIM + "builtin")) { -- cgit v1.2.3 From b662a4577d692329b9ca83525e6039f2ddcd1ac1 Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Sun, 6 Mar 2016 14:31:16 -0500 Subject: Clean up getTime helpers This increases size of the getTime return values to 64 bits. It also removes the TimeGetter classes since the getTime functions are now very precise. --- src/porting.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/porting.cpp') diff --git a/src/porting.cpp b/src/porting.cpp index 8c92a3cba..10b6fc940 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -942,5 +942,18 @@ void attachOrCreateConsole(void) #endif } +// Load performance counter frequency only once at startup +#ifdef _WIN32 + +inline double get_perf_freq() +{ + LARGE_INTEGER freq; + QueryPerformanceFrequency(&freq); + return freq.QuadPart; +} + +double perf_freq = get_perf_freq(); + +#endif } //namespace porting -- cgit v1.2.3