Don't try to load d3dcompiler_46.dll on Windows XP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c
index 16934d5..7f16218 100644
--- a/src/core/windows/SDL_windows.c
+++ b/src/core/windows/SDL_windows.c
@@ -88,6 +88,31 @@ WIN_CoUninitialize(void)
#endif
}
+static BOOL
+IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
+{
+ OSVERSIONINFOEXW osvi;
+ DWORDLONG const dwlConditionMask = VerSetConditionMask(
+ VerSetConditionMask(
+ VerSetConditionMask(
+ 0, VER_MAJORVERSION, VER_GREATER_EQUAL ),
+ VER_MINORVERSION, VER_GREATER_EQUAL ),
+ VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL );
+
+ SDL_zero(osvi);
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ osvi.dwMajorVersion = wMajorVersion;
+ osvi.dwMinorVersion = wMinorVersion;
+ osvi.wServicePackMajor = wServicePackMajor;
+
+ return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
+}
+
+BOOL WIN_IsWindowsVistaOrGreater()
+{
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
+}
+
#endif /* __WIN32__ */
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h
index 45c9d73..bb563cc 100644
--- a/src/core/windows/SDL_windows.h
+++ b/src/core/windows/SDL_windows.h
@@ -56,6 +56,9 @@ extern int WIN_SetError(const char *prefix);
extern HRESULT WIN_CoInitialize(void);
extern void WIN_CoUninitialize(void);
+/* Returns SDL_TRUE if we're running on Windows Vista and newer */
+extern BOOL WIN_IsWindowsVistaOrGreater();
+
#endif /* _INCLUDED_WINDOWS_H */
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index e0efa64..cb0cfe2 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -135,8 +135,11 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER);
if (!d3dcompiler) {
- /* By default we load the Vista+ compatible compiler */
- d3dcompiler = "d3dcompiler_46.dll";
+ if (WIN_IsWindowsVistaOrGreater()) {
+ d3dcompiler = "d3dcompiler_46.dll";
+ } else {
+ d3dcompiler = "none";
+ }
}
if (SDL_strcasecmp(d3dcompiler, "none") != 0) {
SDL_LoadObject(d3dcompiler);