Hello all,
I have started to make swi-prolog bindings to the C multimedia library SDL: GitHub - kwon-young/sdlpl: SWI-Prolog bindings to SDL
For now, I have used the C Foreign Language Interface documented here: SWI-Prolog -- Foreign Language Interface
Here is my experience and a few questions for those of you that are more knowledgeable than me:
- Should I be using the C++ interface instead ? @peter.ludemann mentionned to me privately that using C++ simplifies error handling. I did not have the time to read the C++ interface documentation yetâŚ
- How should I hande foreign data ? SDL functions can returns handles to things like surfaces or textures that should be freed in order.
setup_call_cleanup
is great when knowing the lifetime of the handle beforehand (like the handle for a window) but not great when dealing with textures that can be freed anytime. I tried to use Blobs but I donât think we can impose freeing order on them (like all image textures should be freed before doingimage_quit
. - How should I handle C flags arguments ? For now, Iâm converting prolog atoms to integers and ORing them in prolog for readability. Is there a better solution ?
As a more general question, is anyboy interested on colaborating on this project ?
How about we write small reference games with it like a pong or snake ?
Or a small immediate mode gui framework for visualising things like clpfd constraints labelling (sudoku or n-queens) ?
Or a gui framework like QML (in the C++ Qt) world where we can declaratively specifiy the gui in a dict ?