Do not use SDL_RWFromFile on Windows

It does not work in the MSVC build of SDL2 (although it works in
Mingw-w64's SDL2 package).

Fixes #11.
This commit is contained in:
kichikuou
2021-07-08 17:08:20 +09:00
parent 2c5eb170e2
commit 98038a5c74
3 changed files with 16 additions and 7 deletions
+13
View File
@@ -23,3 +23,16 @@ SDL_RWops* open_resource(const char* name, const char* type) {
return SDL_RWFromFile(path, "rb");
#endif
}
SDL_RWops* open_file(const char* name) {
#ifdef __ANDROID__
// We cannot use SDL_RWFromFile() because it does not resolve relative
// paths using the current directory on Android.
FILE *fp = fopen(name, "rb");
if (!fp)
return NULL;
return SDL_RWFromFP(fp, SDL_TRUE);
#else
return SDL_RWFromFile(name, "rb");
#endif
}