From 49cc0f54ad7b6319d435ca462936dae0cd1c6ad9 Mon Sep 17 00:00:00 2001 From: cutealien Date: Sat, 1 Apr 2017 16:26:31 +0000 Subject: [PATCH] Merge branch releases/1.8 revisions r5369:r5387 into trunk. - Fix bug in cursor positions when compiled with newer Windows SDK's (v110 in VS2012) and running on Systems >= Windows Vista in windowed mode. - IOSOperator::getSysteMemory() no longer returns incorrect values with >2GB. - Spelling fixes and documenation git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5388 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 3 +++ include/IOSOperator.h | 6 +++--- source/Irrlicht/CIrrDeviceWin32.cpp | 16 ++++++++++++++++ source/Irrlicht/CIrrDeviceWin32.h | 21 +++++++++++++++------ source/Irrlicht/COSOperator.cpp | 12 ++++++------ tools/IrrFontTool/newFontTool/CFontTool.cpp | 10 +++++----- tools/IrrFontTool/newFontTool/main.cpp | 2 +- 7 files changed, 49 insertions(+), 21 deletions(-) diff --git a/changes.txt b/changes.txt index 755fd40b..358edfea 100644 --- a/changes.txt +++ b/changes.txt @@ -164,6 +164,9 @@ should now be fps independentn -------------------------- Changes in 1.8.5 + - Fix bug in cursor positions when compiled with newer Windows SDK's (v110 in VS2012) and running on Systems >= Windows Vista in windowed mode. + Thanks @Mustapha Tachouct for the bugreport and patch proposal. Also thanks @BakeMyCake for an earlier report. + - IOSOperator::getSysteMemory() no longer returns incorrect values with >2GB. Thanks @Eduline - human development for report and patch. - Increase KEY_KEY_CODES_COUNT to fix problem with laptop keyboards which return the keycode 0xff for the function key. Thx @Klokancz for bugreport and patch. - Fix bug when calling activateJoysticks on windows several times. It had appened joystick information instead of replacing it, thereby increasing joystick number on each call. Only happened compiling with _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_ (which is the default). Linux and SDL implementation not affected. diff --git a/include/IOSOperator.h b/include/IOSOperator.h index 2ba04172..eeb1856d 100644 --- a/include/IOSOperator.h +++ b/include/IOSOperator.h @@ -38,10 +38,10 @@ public: virtual bool getProcessorSpeedMHz(u32* MHz) const = 0; //! Get the total and available system RAM - /** \param Total: will contain the total system memory - \param Avail: will contain the available memory + /** \param totalBytes: will contain the total system memory in bytes + \param availableBytes: will contain the available memory in bytes \return True if successful, false if not */ - virtual bool getSystemMemory(u32* Total, u32* Avail) const = 0; + virtual bool getSystemMemory(u32* totalBytes, u32* availableBytes) const = 0; }; diff --git a/source/Irrlicht/CIrrDeviceWin32.cpp b/source/Irrlicht/CIrrDeviceWin32.cpp index 7e43b771..e6dce142 100644 --- a/source/Irrlicht/CIrrDeviceWin32.cpp +++ b/source/Irrlicht/CIrrDeviceWin32.cpp @@ -1955,6 +1955,22 @@ void CIrrDeviceWin32::ReportLastWinApiError() } } +// Same function Windows offers in VersionHelpers.h, but we can't use that as it's not available in older sdk's (minimum is SDK 8.1) +bool CIrrDeviceWin32::isWindowsVistaOrGreater() +{ + OSVERSIONINFOEX osvi; + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + osvi.dwMajorVersion = 6; // Windows Vista + + if ( !GetVersionEx((OSVERSIONINFO*)&osvi) ) + { + return false; + } + + return VerifyVersionInfo(&osvi, VER_MAJORVERSION, VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL)); +} + // Convert an Irrlicht texture to a Windows cursor // Based on http://www.codeguru.com/cpp/w-p/win32/cursors/article.php/c4529/ HCURSOR CIrrDeviceWin32::TextureToCursor(HWND hwnd, irr::video::ITexture * tex, const core::rect& sourceRect, const core::position2d &hotspot) diff --git a/source/Irrlicht/CIrrDeviceWin32.h b/source/Irrlicht/CIrrDeviceWin32.h index 171c8f02..e9e0535a 100644 --- a/source/Irrlicht/CIrrDeviceWin32.h +++ b/source/Irrlicht/CIrrDeviceWin32.h @@ -118,13 +118,16 @@ namespace irr return CIrrDeviceStub::checkSuccessiveClicks(mouseX, mouseY, inputEvent ); } - //! switchs to fullscreen + //! Switch to fullscreen bool switchToFullScreen(bool reset=false); //! Check for and show last Windows API error to help internal debugging. - //! Does call GetLastError and on errors formats the errortext and displays it in a messagebox. + //! Does call GetLastError and on errors formats the error text and displays it in a messagebox. static void ReportLastWinApiError(); + //! Same function Windows offers in VersionHelpers.h, but we can't use that as it's not available before SDK 8.1 + static bool isWindowsVistaOrGreater(); + // convert an Irrlicht texture to a windows cursor HCURSOR TextureToCursor(HWND hwnd, irr::video::ITexture * tex, const core::rect& sourceRect, const core::position2d &hotspot); @@ -282,15 +285,21 @@ namespace irr { if (!fullscreen) { + s32 paddingBorder = 0; + #if defined (SM_CXPADDEDBORDER) + if (CIrrDeviceWin32::isWindowsVistaOrGreater()) + paddingBorder = GetSystemMetrics(SM_CXPADDEDBORDER); + #endif + if (resizable) { - BorderX = GetSystemMetrics(SM_CXSIZEFRAME); - BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYSIZEFRAME); + BorderX = GetSystemMetrics(SM_CXSIZEFRAME) + paddingBorder; + BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYSIZEFRAME) + paddingBorder; } else { - BorderX = GetSystemMetrics(SM_CXDLGFRAME); - BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME); + BorderX = GetSystemMetrics(SM_CXDLGFRAME) + paddingBorder; + BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME) + paddingBorder; } } else diff --git a/source/Irrlicht/COSOperator.cpp b/source/Irrlicht/COSOperator.cpp index f9bd51ce..7196aafa 100644 --- a/source/Irrlicht/COSOperator.cpp +++ b/source/Irrlicht/COSOperator.cpp @@ -206,16 +206,16 @@ bool COSOperator::getProcessorSpeedMHz(u32* MHz) const bool COSOperator::getSystemMemory(u32* Total, u32* Avail) const { #if defined(_IRR_WINDOWS_API_) && !defined (_IRR_XBOX_PLATFORM_) - MEMORYSTATUS MemoryStatus; - MemoryStatus.dwLength = sizeof(MEMORYSTATUS); + MEMORYSTATUSEX MemoryStatusEx; + MemoryStatusEx.dwLength = sizeof(MEMORYSTATUSEX); // cannot fail - GlobalMemoryStatus(&MemoryStatus); + GlobalMemoryStatusEx(&MemoryStatusEx); if (Total) - *Total = (u32)(MemoryStatus.dwTotalPhys>>10); + *Total = (u32)(MemoryStatusEx.ullTotalPhys>>10); if (Avail) - *Avail = (u32)(MemoryStatus.dwAvailPhys>>10); + *Avail = (u32)(MemoryStatusEx.ullAvailPhys>>10); return true; @@ -234,7 +234,7 @@ bool COSOperator::getSystemMemory(u32* Total, u32* Avail) const *Avail = (u32)((ps*(long long)ap)>>10); return true; #else - // TODO: implement for non-availablity of symbols/features + // TODO: implement for non-availability of symbols/features return false; #endif #elif defined(_IRR_OSX_PLATFORM_) diff --git a/tools/IrrFontTool/newFontTool/CFontTool.cpp b/tools/IrrFontTool/newFontTool/CFontTool.cpp index 780e9b05..7c957ed9 100644 --- a/tools/IrrFontTool/newFontTool/CFontTool.cpp +++ b/tools/IrrFontTool/newFontTool/CFontTool.cpp @@ -132,7 +132,7 @@ inline u32 getTextureSizeFromSurfaceSize(u32 size) wchar_t currentchar = ch; if ( IsDBCSLeadByte((BYTE) ch)) - continue; // surragate pairs unsupported + continue; // surrogate pairs unsupported // get the dimensions SIZE size; @@ -144,9 +144,9 @@ inline u32 getTextureSizeFromSurfaceSize(u32 size) if (GetCharABCWidthsW(dc, currentchar, currentchar, &abc)) // for unicode fonts, get overhang, underhang, width { - size.cx = abc.abcB; - fa.underhang = abc.abcA; - fa.overhang = abc.abcC; + size.cx = abc.abcB; // full font width (ignoring padding/underhang ) + fa.underhang = abc.abcA; // underhang/padding left - can also be negative (in which case it's overhang left) + fa.overhang = abc.abcC; // overhang/padding right - can also be negative (in which case it's underhand right) if (abc.abcB-abc.abcA+abc.abcC<1) continue; // nothing of width 0 @@ -236,7 +236,7 @@ inline u32 getTextureSizeFromSurfaceSize(u32 size) { s32 currentArea = (*it).getValue(); wchar_t wch = (*it).getKey(); - // sloppy but I couldnt be bothered rewriting it + // sloppy but I couldn't be bothered rewriting it if (Areas[currentArea].sourceimage == currentImage) { // draw letter diff --git a/tools/IrrFontTool/newFontTool/main.cpp b/tools/IrrFontTool/newFontTool/main.cpp index b6f85d7e..2b36547e 100644 --- a/tools/IrrFontTool/newFontTool/main.cpp +++ b/tools/IrrFontTool/newFontTool/main.cpp @@ -2,7 +2,7 @@ Tool for creating Irrlicht bitmap+vector fonts, started by Gaz Davidson in December 2006 - Due to my laziness and Microsoft's unituitive API, surragate pairs and + Due to my laziness and Microsoft's unintuitive API, surrogate pairs and nonspacing diacritical marks are not supported! Linux bitmap font support added by Neil Burlock Oct 2008