Skip to content

Runtime

GAMINGNOOBdev edited this page Jun 14, 2025 · 6 revisions

Embedding the runtime

Since this entire project was designed to be used with a game engine, it is also very easy to embed into other programs/projects. In the following few sections, you will be guided through the process of embedding the runtime step by step.
> Note: example code is mostly written in C

Initializing the runtime

Initializing the runtime is as easy as calling baranium_init(). The return value of baranium_init is a pointer to the runtime handle.
However simply initializing the runtime is not enough. The newly initialized runtime has to be set as the new current context which can be done using baranium_set_context, since multiple runtimes can be created at once.
> Note: Only one runtime can be the current context

In order to properly close the runtime handle, the user has to call baranium_cleanup at the end of execution with the appropriate runtime handle as an argument. Otherwise memory leaks will occur.

Example:

#include <baranium/runtime.h>

int main(const int argc, const char* argv[])
{
    // do stuff ...

    // create and store the context
    baranium_runtime* runtime = baranium_init();
    baranium_set_context(runtime); // set the current context

    // do some runtime stuff ...

    baranium_cleanup(runtime);

    // other cleanup stuff ...
}

Opening scripts

work in progress...

Clone this wiki locally