fallahn / crogine

SDL2 Based Game Framework
82 stars 12 forks source link

why crogine is not based on SFML? #17

Open ghost opened 4 years ago

ghost commented 4 years ago

Hello. I'm newbie in programming and I've installed SFML yesterday. I saw your xygine game engine is based on SFML and does NOT support mobile devices and 3d , but your crogine game engine that is based on SDL2 supports mobile devices and 3d. now I think that SDL2 is better than SFML in mobile and 3d programming. is it true? based on your library selection for your engines I think I must choose SDL2 for mobile and 3d and not SFML.

fallahn commented 4 years ago

Hi. It's true, in my opinion, that SFML is not very good for mobile development. If you're using SFML for window/events however, it is perfectly fine for making 3D in pure OpenGL (here is a good example). The problem I found was that it is very difficult to mix 3D in SFML (if you're using OpenGL 3+) with SFML's graphics module which uses OpenGL 2.1. SFML excels at 2D rendering and has a fantastic API which I consider far easier to use than SDL2's - this is why my 2D engine uses SFML, because it is clean and easy to use so it is much quicker to make games, and I spend less time on lower level game engine programming. Also worth noting is that SFML has a very nice audio module, compared to SDL2's low level interface. SFML also has a networking module, which SDL2 does not.

That being said, if you're prepared to tackle the C interface (or just prefer C) of SDL2 you will most likely find that SDL2 is more feature rich, particularly when cross platform programming. For example SDL2 has file system functions for opening and closing files on all platforms, including mobile, which might not otherwise work with the standard library (in the past I've found it very difficult to use std::fstream on android for example). SDL2 also has support for controller haptics and keyboard scancodes which SFML does not. Ultimately I have 2 engines for two different uses - although if you dig into them you'll find that the API of crogine is very similar to that of xygine, which in turn is very much based on the API of SFML... :) As for which library you choose I can only suggest you look at the criteria for your project, and compare each library to see which best matches those criteria. HTH!

ghost commented 4 years ago

My goal is mobile programming. I just read an article on your blog that you wrote; "SDL2 does not run as a native activity application, rather it needs to be linked and invoked via a java activity so that hardware events such as input may be correctly handed down to the native code." it means that crogine can't build native android games? in other words games made with crogine must compile to java code for run on android?

fallahn commented 4 years ago

No. SDL2 compiles as a binary library as usual, but the game code/crogine code also compiles as a library for android too (instead of a stand alone executable). Then a very small java program is used to launch the game and forward all the events/input to SDL2 and crogine, by calling into the native code. SDL2 comes with a sample application to demonstrate this which can be built with the android SDK/NDK or if you're using visual studio I have an example repository here. In essence the java portion just acts as an entry point, the game itself is still native code. SDL_main() even handles all this (you replace your main() with it) so that the same code runs on all SDL2 platforms.