Don't try to load d3dcompiler_46.dll on Windows XP

This commit is contained in:
Sam Lantinga 2014-04-23 13:47:42 -07:00
parent af395e970e
commit acbc321c2a
3 changed files with 33 additions and 2 deletions

View File

@ -88,6 +88,31 @@ WIN_CoUninitialize(void)
#endif #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__ */ #endif /* __WIN32__ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View File

@ -56,6 +56,9 @@ extern int WIN_SetError(const char *prefix);
extern HRESULT WIN_CoInitialize(void); extern HRESULT WIN_CoInitialize(void);
extern void WIN_CoUninitialize(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 */ #endif /* _INCLUDED_WINDOWS_H */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View File

@ -135,8 +135,11 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT #if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER); d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER);
if (!d3dcompiler) { if (!d3dcompiler) {
/* By default we load the Vista+ compatible compiler */ if (WIN_IsWindowsVistaOrGreater()) {
d3dcompiler = "d3dcompiler_46.dll"; d3dcompiler = "d3dcompiler_46.dll";
} else {
d3dcompiler = "none";
}
} }
if (SDL_strcasecmp(d3dcompiler, "none") != 0) { if (SDL_strcasecmp(d3dcompiler, "none") != 0) {
SDL_LoadObject(d3dcompiler); SDL_LoadObject(d3dcompiler);