Here be the wren bindings.
to use, copy wrap_imgui_codegen.cpp and wrap_imgui_codegen.h, and imgui itself, into your project. I would strongly recommend using the version of imgui checked into this repo to avoid version differences: if you would like to use a different version I would update that submodule and re-run the bindings script instead of using these bindings as-is.
Then once you've got it building, you can expose it to wren's import system:
#include "wrap_imgui_codegen.h"
char* loadModule(WrenVM* vm, const char* name)
{
if(strcmp(name, "imgui") == 0) {
return wrap_imgui::loadModule(vm);
}
return nullptr;
}
WrenForeignClassMethods bindForeignClass(
WrenVM* vm, const char* module, const char* className)
{
WrenForeignClassMethods methods = { NULL, NULL };
if(strcmp(module, "imgui") == 0) {
if(wrap_imgui::bindForeignClass(vm, className, methods))
{
return methods;
}
}
return methods;
}
WrenForeignMethodFn bindForeignMethodFn(
WrenVM* vm,
const char* module,
const char* className,
bool isStatic,
const char* signature)
{
if(strcmp(module, "imgui") == 0) {
return wrap_imgui::bindForeignMethod(vm, className, isStatic, signature);
}
return nullptr;
}
The straightforward list of what is and isn't implemented from imgui is at api_details.md. This is autogenerated and will always be up-to-date with the version of the bindings that gets checked in. For the most part you can read the source of imgui.h to understand more about each method. Some mechanical notes:
- out parameters are handled by a helper "Box" class. compound data types, like ImVec2, does not need to be boxed, but primitive types like numbers and strings do.
var numBox = Box.new(10)
var changed = ImGui.DragFloat("my float", numBox)
System.print(numBox.value)
- Enums can either be provided as raw numbers, or strings
ImGui.Begin("MyWindow", Box.new(true), 0) // number
ImGui.Begin("MyWindow", Box.new(true), "NoTitleBar") // single enum
ImGui.Begin("MyWindow", Box.new(true), "AlwaysAutoResize|NoTitleBar") // enum flags