Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
DekiPlugin.h File Reference

Plugin interface for Deki engine extensions. More...

Macros

#define DEKI_PLUGIN_API   __attribute__((visibility("default")))

Functions

DEKI_PLUGIN_API const char * DekiPlugin_GetName (void)
 Get the plugin name for display in the editor.
DEKI_PLUGIN_API const char * DekiPlugin_GetVersion (void)
 Get the plugin version.
DEKI_PLUGIN_API int DekiPlugin_Init (void)
 Optional: Initialize the plugin.
DEKI_PLUGIN_API void DekiPlugin_Shutdown (void)
 Optional: Shutdown the plugin.
DEKI_PLUGIN_API int DekiPlugin_GetComponentCount (void)
 Get the number of components provided by this plugin.
DEKI_PLUGIN_API const void * DekiPlugin_GetComponentMeta (int index)
 Get component metadata by index.
DEKI_PLUGIN_API void DekiPlugin_RegisterComponents (void)
 Register all plugin components with the engine's ComponentRegistry.
DEKI_PLUGIN_API void DekiPlugin_SetImGuiContext (void *context)
 Receive the editor's ImGui context.
DEKI_PLUGIN_API unsigned int DekiPlugin_GetImGuiContextSize (void)
 Report sizeof(ImGuiContext) as this package compiled it.
DEKI_PLUGIN_API void DekiPlugin_ClearRegistries (void)
 Drop everything this package registered into engine-side registries.
DEKI_PLUGIN_API void DekiPlugin_OnPlayModeStart (void *scene)
 Play mode is starting, for the given Scene*.
DEKI_PLUGIN_API void DekiPlugin_OnPlayModeStop (void)
 Play mode has stopped.

Detailed Description

Plugin interface for Deki engine extensions.

Game projects create a DLL that exports these functions to register custom components with the editor. The editor loads these plugins at runtime when opening a project.

Usage:

  1. Include this header in your game project
  2. Implement the required exported functions
  3. Build as a shared library (DLL/so/dylib)
  4. Place in your project's bin/ directory

Every symbol the editor looks for is declared below, and nothing else is looked for. Two things had drifted before this header was made the single source of truth:

  • It declared DekiPlugin_GetReflectionJson, GetFeatureCount and GetFeature, which all 24 packages dutifully exported and which no loader has ever resolved. Feature metadata is read from package.json, not from the DLL.
  • The loader resolved SetImGuiContext, GetImGuiContextSize, ClearRegistries, OnPlayModeStart and OnPlayModeStop, none of which were declared here.

Example implementation:

#include <DekiPlugin.h>
DEKI_PLUGIN_API const char* DekiPlugin_GetName(void) { return "MyGame"; }
DEKI_PLUGIN_API const char* DekiPlugin_GetVersion(void) { return "1.0.0"; }
DEKI_PLUGIN_API int DekiPlugin_Init(void) { return 0; }
DEKI_PLUGIN_API void DekiPlugin_RegisterComponents(void) { MyGame_Register(); }
Plugin interface for Deki engine extensions.
DEKI_PLUGIN_API const char * DekiPlugin_GetVersion(void)
Get the plugin version.
#define DEKI_PLUGIN_API
Definition DekiPlugin.h:50
DEKI_PLUGIN_API void DekiPlugin_RegisterComponents(void)
Register all plugin components with the engine's ComponentRegistry.
DEKI_PLUGIN_API int DekiPlugin_Init(void)
Optional: Initialize the plugin.
DEKI_PLUGIN_API const char * DekiPlugin_GetName(void)
Get the plugin name for display in the editor.
DEKI_PLUGIN_API void DekiPlugin_Shutdown(void)
Optional: Shutdown the plugin.

Macro Definition Documentation

◆ DEKI_PLUGIN_API

#define DEKI_PLUGIN_API   __attribute__((visibility("default")))

Function Documentation

◆ DekiPlugin_GetName()

DEKI_PLUGIN_API const char * DekiPlugin_GetName ( void )

Get the plugin name for display in the editor.

Returns
Human-readable plugin name (e.g., "Project-V Components")

◆ DekiPlugin_GetVersion()

DEKI_PLUGIN_API const char * DekiPlugin_GetVersion ( void )

Get the plugin version.

Returns
Version string (e.g., "1.0.0")

◆ DekiPlugin_Init()

DEKI_PLUGIN_API int DekiPlugin_Init ( void )

Optional: Initialize the plugin.

Returns
0 on success, non-zero on failure

◆ DekiPlugin_Shutdown()

DEKI_PLUGIN_API void DekiPlugin_Shutdown ( void )

Optional: Shutdown the plugin.

◆ DekiPlugin_GetComponentCount()

DEKI_PLUGIN_API int DekiPlugin_GetComponentCount ( void )

Get the number of components provided by this plugin.

Returns
Number of components (0 if plugin only provides JSON metadata)

◆ DekiPlugin_GetComponentMeta()

DEKI_PLUGIN_API const void * DekiPlugin_GetComponentMeta ( int index)

Get component metadata by index.

Parameters
indexComponent index (0 to GetComponentCount()-1)
Returns
Pointer to component metadata, or nullptr if index is invalid

The returned DekiComponentMeta includes a factory function that can create instances of the component. This enables the editor to instantiate plugin components for play mode.

◆ DekiPlugin_RegisterComponents()

DEKI_PLUGIN_API void DekiPlugin_RegisterComponents ( void )

Register all plugin components with the engine's ComponentRegistry.

Called by the editor after loading the plugin DLL. This allows the plugin to register its components so they appear in the Add Component menu.

◆ DekiPlugin_SetImGuiContext()

DEKI_PLUGIN_API void DekiPlugin_SetImGuiContext ( void * context)

Receive the editor's ImGui context.

Only needed by packages that call ImGui directly. Note that none currently do — they draw through deki-editor's EditorUI, which shares the context via Deki::SetImGuiContext.

◆ DekiPlugin_GetImGuiContextSize()

DEKI_PLUGIN_API unsigned int DekiPlugin_GetImGuiContextSize ( void )

Report sizeof(ImGuiContext) as this package compiled it.

The loader compares this against its own and refuses the package on a mismatch, rather than letting it corrupt the shared context. A package that does not export it is loaded unchecked — so export it if you touch ImGui at all.

◆ DekiPlugin_ClearRegistries()

DEKI_PLUGIN_API void DekiPlugin_ClearRegistries ( void )

Drop everything this package registered into engine-side registries.

Called before the package's DLL is unloaded for a hot reload. Anything holding a pointer into this DLL — factories, std::function callbacks, metadata — must go here, or it dangles the moment FreeLibrary runs.

◆ DekiPlugin_OnPlayModeStart()

DEKI_PLUGIN_API void DekiPlugin_OnPlayModeStart ( void * scene)

Play mode is starting, for the given Scene*.

◆ DekiPlugin_OnPlayModeStop()

DEKI_PLUGIN_API void DekiPlugin_OnPlayModeStop ( void )

Play mode has stopped.