Why didn't FB use SDL for its graphic commands?
-
- Posts: 3909
- Joined: Jan 01, 2009 7:03
- Location: Australia
Why didn't FB use SDL for its graphic commands?
While learning Python I noticed that the library pygame uses SDL for its graphics and other things and I wondered why FreeBASIC didn't do the same. Yes I know you can use the SDL library with FreeBASIC although for some reason today when I tried the example code it throws up something not found errors which is annoying to have to fix yet again when the graphic commands of FreeBASIC just work without any problem. However SDL does have sound and so if FreeBASIC had used SDL to write its innate functions maybe games would have been easier to write? I don't understand (know about) the inner workings of the FreeBASIC compiler so I don't know where its graphics code comes from.
Re: Why didn't FB use SDL for its graphic commands?
The graphics library is found in the git repo under src/gfxlib. There are a number of platform-specifc backends in there. Interestingly when you compile FB code with Emscripten to run in a web browser, the graphics library uses SDL (backend is called "js") because SDL is part of the webassembly runtime that Emscripten uses.
As to why the FB runtime uses native graphics calls on each platform, I imagine that is to reduce the number of dependencies a FB binary depends on. Also there is the licensing of SDL to consider. Back in the early days of FB, SDL1 was LGPL licensed, which would have meant that it would be impossible to statically link it to a FB-compiled executable. And shipping a shared library with you binary would be a pain and you still have to comply with the license.
As to why the FB runtime uses native graphics calls on each platform, I imagine that is to reduce the number of dependencies a FB binary depends on. Also there is the licensing of SDL to consider. Back in the early days of FB, SDL1 was LGPL licensed, which would have meant that it would be impossible to statically link it to a FB-compiled executable. And shipping a shared library with you binary would be a pain and you still have to comply with the license.
Re: Why didn't FB use SDL for its graphic commands?
And IIRC SDL2 has weird and hackish ways of establishing the mainloop. It is also often more event driven oriented than older graphics libraries, making it a bad fit for legacy code.
-
- Posts: 3909
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Why didn't FB use SDL for its graphic commands?
@caeih
@marcov
Thanks for the explanations. Not that i really understood them. But at least I know there was a reason. However, all that under the hood stuff is beyond me The reason I used FreeBASIC in the first place.
@marcov
Thanks for the explanations. Not that i really understood them. But at least I know there was a reason. However, all that under the hood stuff is beyond me The reason I used FreeBASIC in the first place.