Hi everyone,
Lately I've been playing around with SFML 2.5.1 on Android (I'm currently using it at the core of a ruby based engine, where SFML is used in a dynamic library (so) file).
Things work pretty well, but for modularity reasons (the engine should be able to load different games with various resources), I need to externalize loaded resources from any directory location of the Android device.
Meaning that, I want to specify an explicit filesystem location
while using the existing internal SFML loaders functions `loadXXXFromFile`, and
not having to explicitely load everything in memory on the ruby side then pass it to SFML using `loadFromMemory`.
I would suggest adding a CMake constant `SFML_SYSTEM_USE_FS` instead of directly testing on the platform `SFML_SYSTEM_ANDROID`.
Of course, the constant would not be defined by default on Android, but would be on other platforms.
Example : Line 120 of 'src/SFML/Graphics/Image.cpp' would be something like
bool Image::loadFromFile(const std::string& filename)
{
#ifdef SFML_SYSTEM_USE_FS
return priv::ImageLoader::getInstance().loadImageFromFile(filename, m_pixels, m_size);
#else
priv::ResourceStream stream(filename);
return loadFromStream(stream);
#endif
}
And the same goes for `Font.cpp`.
What do you think about this request ?
If the community agree with it, I'm able to push the changes in a Pull Request on the official repository.
End note :
Currently, I'm patching SFML 2.5.1 to suppress the if preprocessor directive.