Skip to content

Commit

Permalink
Don't try to load d3dcompiler_46.dll on Windows XP
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Apr 23, 2014
1 parent af395e9 commit acbc321
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
25 changes: 25 additions & 0 deletions src/core/windows/SDL_windows.c
Expand Up @@ -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: */
3 changes: 3 additions & 0 deletions src/core/windows/SDL_windows.h
Expand Up @@ -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: */
7 changes: 5 additions & 2 deletions src/video/SDL_egl.c
Expand Up @@ -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);
Expand Down

0 comments on commit acbc321

Please sign in to comment.