suikki / simpleSDL

A simple crossplatform libSDL cmake build environment example/test.
MIT License
47 stars 6 forks source link

How to include assets? #2

Closed v1993 closed 5 years ago

v1993 commented 5 years ago

Hello. You project is great, but I miss one important point from it: how can I add assets to my SDL application, like images and fonts? Can you, please, extend example or at least provide some helpful links?

Thank you.

suikki commented 5 years ago

I updated the project a bit and added another example that is using the SDL drawing api instead of OpenGL. It loads a bmp bitmap from a file as an example. Loading images to show as opengl texture is a much more complex thing.

Note that SDL does not know how to load better formats like png and jpg by itself. You would need to use additional library like SDL_image (or my favorite little image loader stb_image).

v1993 commented 5 years ago

Thank you! Didn't expected such a quick reaction. Pretty surprised that android include assets by default too.

As a sidenote: can you, please, link with dynamic SDL libraries instead of building them by youself? You can check if one is availabe and build your SDL only if no were found. You'll need some SDL2 searcher module, like https://github.com/aminosbh/sdl2-cmake-modules. It can save time and space on Linux/Windows/MacOS.

Thanks.

suikki commented 5 years ago

No problem.

As a sidenote: can you, please, link with dynamic SDL libraries instead of building them by youself?

Yes, It would be very nice, and I have a TODO in the project for that. But I haven't found / haven't had time to come up with a satisfactory solution that does not make the "simpleSDL" project quite a bit more complex.

The problem is the Android build. SDL does not even distribute Android binaries. The idea of this project is to work cross-platform out-of-the-box, so the sources would be needed for Android anyways or some third party built binaries. Neither a very nice solution.