Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML_SYSTEM_ANDROID is a platform, but we should test on features  (Read 2727 times)

0 Members and 1 Guest are viewing this topic.

Scorbutics

  • Newbie
  • *
  • Posts: 2
    • View Profile
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.
« Last Edit: April 23, 2022, 01:11:59 pm by Scorbutics »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: SFML_SYSTEM_ANDROID is a platform, but we should test on features
« Reply #1 on: April 30, 2022, 11:51:35 pm »
I'm not too familiar with the Android setup.

Does that mean, you'd be loading a file from the SD card or similar?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Scorbutics

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: SFML_SYSTEM_ANDROID is a platform, but we should test on features
« Reply #2 on: May 20, 2022, 10:22:20 pm »
Yes, exactly.

I know it might be a little bit slow to load single files, but it would provide a way to load data from an external point of view.
Meaning that you don't have to package everything in the apk file, but will be able to build for example, a "launcher" application that will start some games from any location on the SD card.