Skip to content

C and C++

The C++17 runtime is the base of the Godot addon and of the Swift and Flutter runtimes. It has a stable C API (openbone.h) for other languages, runs document scripts in an embedded QuickJS, and ships integrations for Godot, Unreal Engine 5, Cocos2d-x, SDL2, SFML and GLFW/OpenGL. It passes the same conformance suite as every other runtime.

From a checkout (QuickJS and nlohmann/json are vendored, so there is nothing else to fetch):

add_subdirectory(path/to/open-bone/runtimes/cpp)
target_link_libraries(my_game PRIVATE openbone)

Load .obone (JSON) or .obonb (binary) files; images are paths relative to the file or embedded data: URLs.

The Export dialog with Binary selected for the Knight
#include <openbone/runtime.hpp>
auto doc = openbone::loadFile("knight.obone"); // .obone or .obonb
openbone::Instance inst(doc, openbone::createQuickJsHost());
inst.onEvent = [](const openbone::FiredEvent& e) { /* footstep, hit… */ };
inst.onAudio = [](const openbone::AudioCommand& c) { /* play / stop / fade → your audio engine */ };
inst.useStateMachine("knight"); // or inst.play("walk", true);
inst.stateMachine->setInput("speed", openbone::Value::number(0.5));
inst.stateMachine->fire("attack");
inst.pointer(openbone::PointerEvent::Down, x, y); // skeleton space, y up
inst.advance(dt);
for (const openbone::DrawItem& it : inst.drawList().items) {
// vertices, uvs, indices, colour (or per-vertex colours), texture, blend, two-colour tint, clip, text
}

The draw list is engine-neutral: triangles with UVs, colours, a blend mode and clipping, batched by texture. The runtime reference shows how to draw it, and the engine folders have complete integrations:

Engine Where
Godot 4 The Godot addon
Unreal Engine 5 runtimes/cpp/engines/unreal
Cocos2d-x 4 runtimes/cpp/engines/cocos2dx
SDL2, SFML runtimes/cpp/engines/sdl2, runtimes/cpp/engines/sfml (with sound)
GLFW / OpenGL 3.3 runtimes/cpp/engines/glfw

Reference: C / C++ runtime

OpenBone is MIT licensed and made by UXCentury. The example art, voices and sounds are credited in the repository.