I would like to add scripting capabilities to my C++ game engine.
I have Engine.exe
, Physics.dll
, Audio.dll
and I'm adding Scripting.dll
which is a high-level Racket wrapper.
Engine.exe
loads Physics.dll
and sets up physics world, loads Audio.dll
and sets up audio world. It is supposed to load Scripting.dll
, to set up bindings to Physics.dll
, Audio.dll
and to load game scripts.
AFAIK there are two possible ways to embed Racket into a C++ program:
Using Foreign Interface seems bizarre due to necessity to load Physics.dll
, Audio.dll
two times: first from Engine.exe
and then from the game script.
Writing Extensions looks more appealing, because it allows doing script bindings on C++ side. On the other hand you have to build your extension with raco ctool
, link it with mzdyn
object file — which looks awkward as well: why not make mzdyn
a static library?
I would like to implement a single method, e.g. setupScriptBindings()
, both in Physics.dll
and in Audio.dll
, and to call it from Engine.exe
at the startup.
Is there a straightforward way to do it?