diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-01-16 16:43:04 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-02-22 22:16:07 +0100 |
commit | ef478ade649add1ab1706370ff53bcb0c32798d1 (patch) | |
tree | bf39b20030319377edec1b654fe4e8c7ba4594a3 /src/os/windows | |
parent | af4d32357cc4cea6878c61c366378477e62915d0 (diff) | |
download | openttd-ef478ade649add1ab1706370ff53bcb0c32798d1.tar.xz |
Add: [Win32] Video driver that uses OpenGL to transfer the video buffer to the screen.
Diffstat (limited to 'src/os/windows')
-rw-r--r-- | src/os/windows/win32.cpp | 32 | ||||
-rw-r--r-- | src/os/windows/win32.h | 1 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index 650413d02..ffc4f8c1a 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -820,6 +820,38 @@ int OTTDStringCompare(const char *s1, const char *s2) return CompareString(MAKELCID(_current_language->winlangid, SORT_DEFAULT), NORM_IGNORECASE, s1_buf, -1, s2_buf, -1); } +/** + * Is the current Windows version Vista or later? + * @return True if the current Windows is Vista or later. + */ +bool IsWindowsVistaOrGreater() +{ + typedef BOOL (WINAPI * LPVERIFYVERSIONINFO)(LPOSVERSIONINFOEX, DWORD, DWORDLONG); + typedef ULONGLONG (NTAPI * LPVERSETCONDITIONMASK)(ULONGLONG, DWORD, BYTE); +#ifdef UNICODE + static LPVERIFYVERSIONINFO _VerifyVersionInfo = (LPVERIFYVERSIONINFO)GetProcAddress(GetModuleHandle(_T("Kernel32")), "VerifyVersionInfoW"); +#else + static LPVERIFYVERSIONINFO _VerifyVersionInfo = (LPVERIFYVERSIONINFO)GetProcAddress(GetModuleHandle(_T("Kernel32")), "VerifyVersionInfoA"); +#endif + static LPVERSETCONDITIONMASK _VerSetConditionMask = (LPVERSETCONDITIONMASK)GetProcAddress(GetModuleHandle(_T("Kernel32")), "VerSetConditionMask"); + + if (_VerifyVersionInfo != nullptr && _VerSetConditionMask != nullptr) { + OSVERSIONINFOEX osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 }; + DWORDLONG dwlConditionMask = 0; + dwlConditionMask = _VerSetConditionMask(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL); + dwlConditionMask = _VerSetConditionMask(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL); + dwlConditionMask = _VerSetConditionMask(dwlConditionMask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); + + osvi.dwMajorVersion = 6; + osvi.dwMinorVersion = 0; + osvi.wServicePackMajor = 0; + + return _VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE; + } else { + return LOBYTE(GetVersion()) >= 6; + } +} + #ifdef _MSC_VER /* Based on code from MSDN: https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx */ const DWORD MS_VC_EXCEPTION = 0x406D1388; diff --git a/src/os/windows/win32.h b/src/os/windows/win32.h index 8ffe8ae7b..8cc85865f 100644 --- a/src/os/windows/win32.h +++ b/src/os/windows/win32.h @@ -39,5 +39,6 @@ HRESULT OTTDSHGetFolderPath(HWND, int, HANDLE, DWORD, LPTSTR); void Win32SetCurrentLocaleName(const char *iso_code); int OTTDStringCompare(const char *s1, const char *s2); +bool IsWindowsVistaOrGreater(); #endif /* WIN32_H */ |