Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
DragonBonesModuleEntry.cpp File Reference

The DragonBones side module's exported ABI. More...

#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include "./DragonBonesAdapter.hpp"
#include "./DragonBonesBindings.hpp"
#include "../spine/SkeletalModule.hpp"
Include dependency graph for DragonBonesModuleEntry.cpp:

Go to the source code of this file.

Macros

#define EMSCRIPTEN_KEEPALIVE

Functions

int db_loadSkeleton (uintptr_t skeletonPtr, int skeletonLen, uintptr_t atlasPtr, int atlasLen)
const char * db_getLastError ()
void db_unloadSkeleton (int handle)
const char * db_getArmatures (int handle)
 ["armatureA","armatureB"] — a DragonBones file names more than one.
const char * db_getAtlasImageName (int handle)
 The image this file's atlas expects, so the caller knows what to upload.
void db_setAtlasTexture (int handle, uint32_t textureId)
int db_createInstance (int skeletonHandle, const char *armatureName)
void db_destroyInstance (int instanceId)
int db_playAnimation (int instanceId, const char *name, int playTimes)
 playTimes: -1 keeps what the data says, 0 loops, n plays n times.
int db_fadeInAnimation (int instanceId, const char *name, float fadeSeconds, int playTimes)
 Where Spine would set a mix duration: DragonBones fades at the moment of play.
void db_stopAnimation (int instanceId, const char *name)
void db_setTimeScale (int instanceId, float scale)
void db_setColor (int instanceId, float r, float g, float b, float a)
void db_update (int instanceId, float dt)
const char * db_getAnimations (int instanceId)
const char * db_getBones (int instanceId)
int db_getBonePoses (int instanceId, uintptr_t outPtr, int capacity)
int db_getMeshBatchCount (int instanceId)
int db_getMeshBatchVertexCount (int instanceId, int batchIndex)
int db_getMeshBatchIndexCount (int instanceId, int batchIndex)
void db_getMeshBatchData (int instanceId, int batchIndex, uintptr_t outVerticesPtr, uintptr_t outIndicesPtr, uintptr_t outTextureIdPtr, uintptr_t outBlendModePtr)
void db_getBounds (int instanceId, uintptr_t outXPtr, uintptr_t outYPtr, uintptr_t outWPtr, uintptr_t outHPtr)
int db_runtimeVersion ()
 5 — the DragonBones data format this runtime reads, for the SDK's version gate.

Detailed Description

The DragonBones side module's exported ABI.

Handles, batching, the returned-string storage and the event queue all come from SkeletalModule.hpp, which the Spine module uses for the same things. What is written here is only what DragonBones does differently, and there are three such places worth naming.

ONE FILE HOLDS SEVERAL ARMATURES. Spine's skeleton is the file; a DragonBones file is a project and names its armatures (mecha_2903 ships four). So creating an instance takes an armature name, and db_getArmatures exists at all.

BLENDING IS PER PLAY, NOT A TABLE. Spine mixes through a from/to matrix set on the skeleton; DragonBones fades in when you start an animation. Neither is expressible as the other, so the ABI says fadeIn and does not pretend to have a mix table.

THE ATLAS IS ONE PAGE. Spine's atlas names its pages and the caller binds each; a DragonBones atlas is one image, so the page API here is the degenerate case rather than a second shape for the SDK to learn.

Author
ESEngine Team
Date
2026

Definition in file DragonBonesModuleEntry.cpp.

Macro Definition Documentation

◆ EMSCRIPTEN_KEEPALIVE

Function Documentation

◆ db_createInstance()

int db_createInstance ( int skeletonHandle,
const char * armatureName )

◆ db_destroyInstance()

void db_destroyInstance ( int instanceId)

Definition at line 230 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_fadeInAnimation()

int db_fadeInAnimation ( int instanceId,
const char * name,
float fadeSeconds,
int playTimes )

Where Spine would set a mix duration: DragonBones fades at the moment of play.

Where Spine would set a mix duration: DragonBones fades at the moment of play.

Definition at line 251 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_getAnimations()

const char * db_getAnimations ( int instanceId)

Definition at line 295 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_getArmatures()

const char * db_getArmatures ( int handle)

["armatureA","armatureB"] — a DragonBones file names more than one.

["armatureA","armatureB"] — a DragonBones file names more than one.

Definition at line 179 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_getAtlasImageName()

const char * db_getAtlasImageName ( int handle)

The image this file's atlas expects, so the caller knows what to upload.

Definition at line 189 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_getBonePoses()

int db_getBonePoses ( int instanceId,
uintptr_t outPtr,
int capacity )

Every bone's parent index and pose in one call: 5 floats a bone — parent (-1 for a root), x, y, degrees, length — into outPtr, at most capacity bones; returns how many it wrote. Posed in the y-UP space the geometry leaves the runtime in (see EsArmatureProxy), so the skeleton drawn over the artwork lands on it.

Definition at line 320 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_getBones()

const char * db_getBones ( int instanceId)

The bone names, in the armature's own order — a parent before each of its children.

Definition at line 305 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_getBounds()

void db_getBounds ( int instanceId,
uintptr_t outXPtr,
uintptr_t outYPtr,
uintptr_t outWPtr,
uintptr_t outHPtr )

@heapreturn outXPtr, outYPtr, outWPtr, outHPtr

Definition at line 390 of file DragonBonesModuleEntry.cpp.

References g_ctx, and es::skeletal::VERTEX_FLOATS.

◆ db_getLastError()

const char * db_getLastError ( )

Definition at line 157 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_getMeshBatchCount()

int db_getMeshBatchCount ( int instanceId)

Definition at line 355 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_getMeshBatchData()

void db_getMeshBatchData ( int instanceId,
int batchIndex,
uintptr_t outVerticesPtr,
uintptr_t outIndicesPtr,
uintptr_t outTextureIdPtr,
uintptr_t outBlendModePtr )

◆ db_getMeshBatchIndexCount()

int db_getMeshBatchIndexCount ( int instanceId,
int batchIndex )

Definition at line 368 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_getMeshBatchVertexCount()

int db_getMeshBatchVertexCount ( int instanceId,
int batchIndex )

Definition at line 361 of file DragonBonesModuleEntry.cpp.

References g_ctx, and es::skeletal::VERTEX_FLOATS.

◆ db_loadSkeleton()

int db_loadSkeleton ( uintptr_t skeletonPtr,
int skeletonLen,
uintptr_t atlasPtr,
int atlasLen )

Definition at line 120 of file DragonBonesModuleEntry.cpp.

References g_ctx, and EsFactory::instance().

◆ db_playAnimation()

int db_playAnimation ( int instanceId,
const char * name,
int playTimes )

playTimes: -1 keeps what the data says, 0 loops, n plays n times.

playTimes: -1 keeps what the data says, 0 loops, n plays n times.

Definition at line 243 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_runtimeVersion()

int db_runtimeVersion ( )

5 — the DragonBones data format this runtime reads, for the SDK's version gate.

The DragonBones data format this runtime reads, for the SDK's version gate.

Definition at line 420 of file DragonBonesModuleEntry.cpp.

◆ db_setAtlasTexture()

void db_setAtlasTexture ( int handle,
uint32_t textureId )

Definition at line 195 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_setColor()

void db_setColor ( int instanceId,
float r,
float g,
float b,
float a )

Tint this instance. Multiplied onto each slot's authored colour, so opaque white leaves the armature exactly as it was drawn.

Definition at line 272 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_setTimeScale()

void db_setTimeScale ( int instanceId,
float scale )

Definition at line 264 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_stopAnimation()

void db_stopAnimation ( int instanceId,
const char * name )

Definition at line 258 of file DragonBonesModuleEntry.cpp.

References g_ctx.

◆ db_unloadSkeleton()

void db_unloadSkeleton ( int handle)

Definition at line 160 of file DragonBonesModuleEntry.cpp.

References g_ctx, and EsFactory::instance().

◆ db_update()

void db_update ( int instanceId,
float dt )