|
Polyphase Game Engine
|
Engine API provided to plugins during OnLoad. More...
#include <PolyphaseEngineAPI.h>
Public Attributes | |
| void(* | LogDebug )(const char *fmt,...) |
| Log a debug message. | |
| void(* | LogWarning )(const char *fmt,...) |
| Log a warning message. | |
| void(* | LogError )(const char *fmt,...) |
| Log an error message. | |
| lua_State *(* | GetLua )() |
| Get the main Lua state. | |
| void(* | Lua_settop )(lua_State *L, int idx) |
| void(* | Lua_pushvalue )(lua_State *L, int idx) |
| void(* | Lua_pop )(lua_State *L, int n) |
| int(* | Lua_gettop )(lua_State *L) |
| int(* | Lua_type )(lua_State *L, int idx) |
| int(* | Lua_isfunction )(lua_State *L, int idx) |
| int(* | Lua_istable )(lua_State *L, int idx) |
| int(* | Lua_isuserdata )(lua_State *L, int idx) |
| int(* | Lua_isnil )(lua_State *L, int idx) |
| int(* | Lua_toboolean )(lua_State *L, int idx) |
| double(* | Lua_tonumber )(lua_State *L, int idx) |
| const char *(* | Lua_tostring )(lua_State *L, int idx) |
| void *(* | Lua_touserdata )(lua_State *L, int idx) |
| void(* | Lua_pushnil )(lua_State *L) |
| void(* | Lua_pushboolean )(lua_State *L, int b) |
| void(* | Lua_pushnumber )(lua_State *L, double n) |
| void(* | Lua_pushstring )(lua_State *L, const char *s) |
| void(* | Lua_pushinteger )(lua_State *L, long long n) |
| void *(* | Lua_newuserdata )(lua_State *L, size_t sz) |
| void(* | Lua_createtable )(lua_State *L, int narr, int nrec) |
| void(* | Lua_setfield )(lua_State *L, int idx, const char *k) |
| void(* | Lua_getfield )(lua_State *L, int idx, const char *k) |
| void(* | Lua_setglobal )(lua_State *L, const char *name) |
| void(* | Lua_getglobal )(lua_State *L, const char *name) |
| void(* | Lua_rawset )(lua_State *L, int idx) |
| void(* | Lua_rawget )(lua_State *L, int idx) |
| void(* | Lua_settable )(lua_State *L, int idx) |
| void(* | Lua_gettable )(lua_State *L, int idx) |
| int(* | Lua_setmetatable )(lua_State *L, int objindex) |
| int(* | Lua_getmetatable )(lua_State *L, int objindex) |
| int(* | LuaL_newmetatable )(lua_State *L, const char *tname) |
| void(* | LuaL_setmetatable )(lua_State *L, const char *tname) |
| void *(* | LuaL_checkudata )(lua_State *L, int ud, const char *tname) |
| double(* | LuaL_checknumber )(lua_State *L, int arg) |
| long long(* | LuaL_checkinteger )(lua_State *L, int arg) |
| const char *(* | LuaL_checkstring )(lua_State *L, int arg) |
| void(* | LuaL_setfuncs )(lua_State *L, const void *l, int nup) |
| void(* | LuaL_getmetatable )(lua_State *L, const char *tname) |
| World *(* | GetWorld )(int32_t index) |
| Get a world by index. | |
| int32_t(* | GetNumWorlds )() |
| Get the number of active worlds. | |
| Node *(* | SpawnNode )(World *world, const char *typeName) |
| Spawn a node of the given type in a world. | |
| void(* | DestroyNode )(Node *node) |
| Destroy a node. | |
| Node *(* | FindNode )(World *world, const char *name) |
| Find a node by name in a world. | |
| void(* | Node3D_GetRotation )(Node3D *node, float *outX, float *outY, float *outZ) |
| Get the local rotation of a Node3D in euler angles (degrees). | |
| void(* | Node3D_SetRotation )(Node3D *node, float x, float y, float z) |
| Set the local rotation of a Node3D in euler angles (degrees). | |
| void(* | Node3D_AddRotation )(Node3D *node, float x, float y, float z) |
| Add rotation to a Node3D in euler angles (degrees). | |
| void(* | Node3D_GetPosition )(Node3D *node, float *outX, float *outY, float *outZ) |
| Get the local position of a Node3D. | |
| void(* | Node3D_SetPosition )(Node3D *node, float x, float y, float z) |
| Set the local position of a Node3D. | |
| void(* | Node3D_GetScale )(Node3D *node, float *outX, float *outY, float *outZ) |
| Get the local scale of a Node3D. | |
| void(* | Node3D_SetScale )(Node3D *node, float x, float y, float z) |
| Set the local scale of a Node3D. | |
| Asset *(* | LoadAsset )(const char *name) |
| Load an asset by name (loads from disk if not already loaded). | |
| Asset *(* | FetchAsset )(const char *name) |
| Fetch an asset by name (returns nullptr if not already loaded). | |
| void(* | UnloadAsset )(const char *name) |
| Unload an asset by name. | |
| int32_t(* | TinyLLM_Encode )(Asset *model, const char *text, bool addBos, bool addEos, int32_t *outTokens, int32_t maxTokens) |
| Encode text to tokens using a TinyLLMAsset's tokenizer. | |
| int32_t(* | TinyLLM_Decode )(Asset *model, int32_t prevToken, int32_t token, char *outStr, int32_t maxLen) |
| Decode a token to string using a TinyLLMAsset's tokenizer. | |
| void(* | PlaySound2D )(SoundWave *sound, float volume, float pitch) |
| Play a 2D sound (non-positional). | |
| void(* | StopAllSounds )() |
| Stop all currently playing sounds. | |
| void(* | SetMasterVolume )(float volume) |
| Set the master audio volume. | |
| float(* | GetMasterVolume )() |
| Get the master audio volume. | |
| uint32_t(* | Audio_OpenStream )(uint32_t sampleRate, uint32_t numChannels, uint32_t bitsPerSample) |
| void(* | Audio_CloseStream )(uint32_t streamId) |
| int32_t(* | Audio_SubmitStreamBuffer )(uint32_t streamId, const uint8_t *data, uint32_t byteSize) |
| uint64_t(* | Audio_GetStreamPlayedSamples )(uint32_t streamId) |
| void(* | Audio_SetStreamVolume )(uint32_t streamId, float volume) |
| void(* | Audio_SetStreamPaused )(uint32_t streamId, bool paused) |
| void(* | Audio_FlushStream )(uint32_t streamId) |
| bool(* | IsKeyDown )(int32_t key) |
| Check if a key is currently held down. | |
| bool(* | IsKeyJustPressed )(int32_t key) |
| Check if a key was just pressed this frame. | |
| bool(* | IsKeyJustReleased )(int32_t key) |
| Check if a key was just released this frame. | |
| bool(* | IsMouseButtonDown )(int32_t button) |
| Check if a mouse button is currently held down. | |
| bool(* | IsMouseButtonJustPressed )(int32_t button) |
| Check if a mouse button was just pressed this frame. | |
| void(* | GetMousePosition )(int32_t *x, int32_t *y) |
| Get the current mouse position. | |
| void(* | GetMouseDelta )(int32_t *deltaX, int32_t *deltaY) |
| Get the mouse movement since last frame. | |
| int32_t(* | GetScrollWheelDelta )() |
| Get the scroll wheel delta. | |
| float(* | GetDeltaTime )() |
| Get the time elapsed since last frame (in seconds). | |
| float(* | GetElapsedTime )() |
| Get the total time elapsed since engine start (in seconds). | |
| void(* | Gizmos_SetColor )(float r, float g, float b, float a) |
| Set the gizmo drawing color. | |
| void(* | Gizmos_SetMatrix )(const float *matrix16) |
| Set the gizmo transformation matrix (column-major, 16 floats). | |
| void(* | Gizmos_ResetState )() |
| Reset gizmo state to default (white color, identity matrix). | |
| void(* | Gizmos_DrawCube )(float cx, float cy, float cz, float sx, float sy, float sz) |
| Draw a solid cube gizmo. | |
| void(* | Gizmos_DrawWireCube )(float cx, float cy, float cz, float sx, float sy, float sz) |
| Draw a wireframe cube gizmo. | |
| void(* | Gizmos_DrawSphere )(float cx, float cy, float cz, float radius) |
| Draw a solid sphere gizmo. | |
| void(* | Gizmos_DrawWireSphere )(float cx, float cy, float cz, float radius) |
| Draw a wireframe sphere gizmo. | |
| void(* | Gizmos_DrawLine )(float x0, float y0, float z0, float x1, float y1, float z1) |
| Draw a line gizmo. | |
| void(* | Gizmos_DrawRay )(float ox, float oy, float oz, float dx, float dy, float dz) |
| Draw a ray gizmo (from origin along direction). | |
| EditorUIHooks * | editorUI |
| Pointer to editor UI hooks struct. | |
| void(* | GetImGuiContext )(ImGuiPluginContext *outCtx) |
| Get ImGui context for plugin use (Editor builds only). | |
Engine API provided to plugins during OnLoad.
All function pointers are guaranteed to be valid for the lifetime of the plugin (from OnLoad to OnUnload).
| void(* PolyphaseEngineAPI::Audio_CloseStream) (uint32_t streamId) |
| void(* PolyphaseEngineAPI::Audio_FlushStream) (uint32_t streamId) |
| uint64_t(* PolyphaseEngineAPI::Audio_GetStreamPlayedSamples) (uint32_t streamId) |
| uint32_t(* PolyphaseEngineAPI::Audio_OpenStream) (uint32_t sampleRate, uint32_t numChannels, uint32_t bitsPerSample) |
| void(* PolyphaseEngineAPI::Audio_SetStreamPaused) (uint32_t streamId, bool paused) |
| void(* PolyphaseEngineAPI::Audio_SetStreamVolume) (uint32_t streamId, float volume) |
| int32_t(* PolyphaseEngineAPI::Audio_SubmitStreamBuffer) (uint32_t streamId, const uint8_t *data, uint32_t byteSize) |
| EditorUIHooks* PolyphaseEngineAPI::editorUI |
Pointer to editor UI hooks struct.
This is nullptr in non-editor (game) builds. Check before using to ensure plugin works in both contexts.
| Asset *(* PolyphaseEngineAPI::FetchAsset) (const char *name) |
| float(* PolyphaseEngineAPI::GetDeltaTime) () |
Get the time elapsed since last frame (in seconds).
| float(* PolyphaseEngineAPI::GetElapsedTime) () |
Get the total time elapsed since engine start (in seconds).
| void(* PolyphaseEngineAPI::GetImGuiContext) (ImGuiPluginContext *outCtx) |
Get ImGui context for plugin use (Editor builds only).
Plugins MUST call this in OnLoad and set up ImGui context before calling any ImGui functions. Returns nullptr in non-editor builds.
| outCtx | Pointer to ImGuiPluginContext to fill |
| lua_State *(* PolyphaseEngineAPI::GetLua) () |
Get the main Lua state.
| float(* PolyphaseEngineAPI::GetMasterVolume) () |
Get the master audio volume.
| void(* PolyphaseEngineAPI::GetMouseDelta) (int32_t *deltaX, int32_t *deltaY) |
Get the mouse movement since last frame.
| deltaX | Output: mouse X delta |
| deltaY | Output: mouse Y delta |
| void(* PolyphaseEngineAPI::GetMousePosition) (int32_t *x, int32_t *y) |
Get the current mouse position.
| x | Output: mouse X position |
| y | Output: mouse Y position |
| int32_t(* PolyphaseEngineAPI::GetNumWorlds) () |
Get the number of active worlds.
| int32_t(* PolyphaseEngineAPI::GetScrollWheelDelta) () |
Get the scroll wheel delta.
| World *(* PolyphaseEngineAPI::GetWorld) (int32_t index) |
Get a world by index.
| index | World index (usually 0 for main world) |
| void(* PolyphaseEngineAPI::Gizmos_DrawCube) (float cx, float cy, float cz, float sx, float sy, float sz) |
Draw a solid cube gizmo.
| cx | Center X |
| cy | Center Y |
| cz | Center Z |
| sx | Size X |
| sy | Size Y |
| sz | Size Z |
| void(* PolyphaseEngineAPI::Gizmos_DrawLine) (float x0, float y0, float z0, float x1, float y1, float z1) |
Draw a line gizmo.
| x0 | Start X |
| y0 | Start Y |
| z0 | Start Z |
| x1 | End X |
| y1 | End Y |
| z1 | End Z |
| void(* PolyphaseEngineAPI::Gizmos_DrawRay) (float ox, float oy, float oz, float dx, float dy, float dz) |
Draw a ray gizmo (from origin along direction).
| ox | Origin X |
| oy | Origin Y |
| oz | Origin Z |
| dx | Direction X |
| dy | Direction Y |
| dz | Direction Z |
| void(* PolyphaseEngineAPI::Gizmos_DrawSphere) (float cx, float cy, float cz, float radius) |
Draw a solid sphere gizmo.
| cx | Center X |
| cy | Center Y |
| cz | Center Z |
| radius | Sphere radius |
| void(* PolyphaseEngineAPI::Gizmos_DrawWireCube) (float cx, float cy, float cz, float sx, float sy, float sz) |
Draw a wireframe cube gizmo.
| void(* PolyphaseEngineAPI::Gizmos_DrawWireSphere) (float cx, float cy, float cz, float radius) |
Draw a wireframe sphere gizmo.
| void(* PolyphaseEngineAPI::Gizmos_ResetState) () |
Reset gizmo state to default (white color, identity matrix).
| void(* PolyphaseEngineAPI::Gizmos_SetColor) (float r, float g, float b, float a) |
Set the gizmo drawing color.
| r | Red component (0.0 - 1.0) |
| g | Green component (0.0 - 1.0) |
| b | Blue component (0.0 - 1.0) |
| a | Alpha component (0.0 - 1.0) |
| void(* PolyphaseEngineAPI::Gizmos_SetMatrix) (const float *matrix16) |
Set the gizmo transformation matrix (column-major, 16 floats).
| matrix16 | Pointer to 16 floats (column-major 4x4 matrix) |
| bool(* PolyphaseEngineAPI::IsKeyDown) (int32_t key) |
Check if a key is currently held down.
| key | Key code (from InputConstants.h) |
| bool(* PolyphaseEngineAPI::IsKeyJustPressed) (int32_t key) |
Check if a key was just pressed this frame.
| key | Key code (from InputConstants.h) |
| bool(* PolyphaseEngineAPI::IsKeyJustReleased) (int32_t key) |
Check if a key was just released this frame.
| key | Key code (from InputConstants.h) |
| bool(* PolyphaseEngineAPI::IsMouseButtonDown) (int32_t button) |
Check if a mouse button is currently held down.
| button | Mouse button (0=left, 1=right, 2=middle) |
| bool(* PolyphaseEngineAPI::IsMouseButtonJustPressed) (int32_t button) |
Check if a mouse button was just pressed this frame.
| button | Mouse button (0=left, 1=right, 2=middle) |
| Asset *(* PolyphaseEngineAPI::LoadAsset) (const char *name) |
Load an asset by name (loads from disk if not already loaded).
| name | Asset name |
| void(* PolyphaseEngineAPI::LogDebug) (const char *fmt,...) |
Log a debug message.
| fmt | Printf-style format string |
| void(* PolyphaseEngineAPI::LogError) (const char *fmt,...) |
Log an error message.
| fmt | Printf-style format string |
| void(* PolyphaseEngineAPI::LogWarning) (const char *fmt,...) |
Log a warning message.
| fmt | Printf-style format string |
| void(* PolyphaseEngineAPI::Lua_createtable) (lua_State *L, int narr, int nrec) |
| void(* PolyphaseEngineAPI::Lua_getfield) (lua_State *L, int idx, const char *k) |
| void(* PolyphaseEngineAPI::Lua_getglobal) (lua_State *L, const char *name) |
| int(* PolyphaseEngineAPI::Lua_getmetatable) (lua_State *L, int objindex) |
| void(* PolyphaseEngineAPI::Lua_gettable) (lua_State *L, int idx) |
| int(* PolyphaseEngineAPI::Lua_gettop) (lua_State *L) |
| int(* PolyphaseEngineAPI::Lua_isfunction) (lua_State *L, int idx) |
| int(* PolyphaseEngineAPI::Lua_isnil) (lua_State *L, int idx) |
| int(* PolyphaseEngineAPI::Lua_istable) (lua_State *L, int idx) |
| int(* PolyphaseEngineAPI::Lua_isuserdata) (lua_State *L, int idx) |
| void *(* PolyphaseEngineAPI::Lua_newuserdata) (lua_State *L, size_t sz) |
| void(* PolyphaseEngineAPI::Lua_pop) (lua_State *L, int n) |
| void(* PolyphaseEngineAPI::Lua_pushboolean) (lua_State *L, int b) |
| void(* PolyphaseEngineAPI::Lua_pushinteger) (lua_State *L, long long n) |
| void(* PolyphaseEngineAPI::Lua_pushnil) (lua_State *L) |
| void(* PolyphaseEngineAPI::Lua_pushnumber) (lua_State *L, double n) |
| void(* PolyphaseEngineAPI::Lua_pushstring) (lua_State *L, const char *s) |
| void(* PolyphaseEngineAPI::Lua_pushvalue) (lua_State *L, int idx) |
| void(* PolyphaseEngineAPI::Lua_rawget) (lua_State *L, int idx) |
| void(* PolyphaseEngineAPI::Lua_rawset) (lua_State *L, int idx) |
| void(* PolyphaseEngineAPI::Lua_setfield) (lua_State *L, int idx, const char *k) |
| void(* PolyphaseEngineAPI::Lua_setglobal) (lua_State *L, const char *name) |
| int(* PolyphaseEngineAPI::Lua_setmetatable) (lua_State *L, int objindex) |
| void(* PolyphaseEngineAPI::Lua_settable) (lua_State *L, int idx) |
| void(* PolyphaseEngineAPI::Lua_settop) (lua_State *L, int idx) |
| int(* PolyphaseEngineAPI::Lua_toboolean) (lua_State *L, int idx) |
| double(* PolyphaseEngineAPI::Lua_tonumber) (lua_State *L, int idx) |
| const char *(* PolyphaseEngineAPI::Lua_tostring) (lua_State *L, int idx) |
| void *(* PolyphaseEngineAPI::Lua_touserdata) (lua_State *L, int idx) |
| int(* PolyphaseEngineAPI::Lua_type) (lua_State *L, int idx) |
| long long(* PolyphaseEngineAPI::LuaL_checkinteger) (lua_State *L, int arg) |
| double(* PolyphaseEngineAPI::LuaL_checknumber) (lua_State *L, int arg) |
| const char *(* PolyphaseEngineAPI::LuaL_checkstring) (lua_State *L, int arg) |
| void *(* PolyphaseEngineAPI::LuaL_checkudata) (lua_State *L, int ud, const char *tname) |
| void(* PolyphaseEngineAPI::LuaL_getmetatable) (lua_State *L, const char *tname) |
| int(* PolyphaseEngineAPI::LuaL_newmetatable) (lua_State *L, const char *tname) |
| void(* PolyphaseEngineAPI::LuaL_setfuncs) (lua_State *L, const void *l, int nup) |
| void(* PolyphaseEngineAPI::LuaL_setmetatable) (lua_State *L, const char *tname) |
| void(* PolyphaseEngineAPI::Node3D_AddRotation) (Node3D *node, float x, float y, float z) |
| void(* PolyphaseEngineAPI::Node3D_GetPosition) (Node3D *node, float *outX, float *outY, float *outZ) |
| void(* PolyphaseEngineAPI::Node3D_GetRotation) (Node3D *node, float *outX, float *outY, float *outZ) |
| void(* PolyphaseEngineAPI::Node3D_GetScale) (Node3D *node, float *outX, float *outY, float *outZ) |
| void(* PolyphaseEngineAPI::Node3D_SetPosition) (Node3D *node, float x, float y, float z) |
| void(* PolyphaseEngineAPI::Node3D_SetRotation) (Node3D *node, float x, float y, float z) |
| void(* PolyphaseEngineAPI::Node3D_SetScale) (Node3D *node, float x, float y, float z) |
| void(* PolyphaseEngineAPI::PlaySound2D) (SoundWave *sound, float volume, float pitch) |
Play a 2D sound (non-positional).
| sound | Sound wave asset to play |
| volume | Volume multiplier (0.0 - 1.0+) |
| pitch | Pitch multiplier (1.0 = normal) |
| void(* PolyphaseEngineAPI::SetMasterVolume) (float volume) |
Set the master audio volume.
| volume | Volume (0.0 - 1.0) |
Spawn a node of the given type in a world.
| world | World to spawn in |
| typeName | Type name of node to spawn (e.g., "Mesh3D", "Camera3D") |
| void(* PolyphaseEngineAPI::StopAllSounds) () |
Stop all currently playing sounds.
| int32_t(* PolyphaseEngineAPI::TinyLLM_Decode) (Asset *model, int32_t prevToken, int32_t token, char *outStr, int32_t maxLen) |
Decode a token to string using a TinyLLMAsset's tokenizer.
| model | TinyLLMAsset pointer |
| prevToken | Previous token (for space handling) |
| token | Token to decode |
| outStr | Output buffer (caller allocates) |
| maxLen | Size of output buffer |
| int32_t(* PolyphaseEngineAPI::TinyLLM_Encode) (Asset *model, const char *text, bool addBos, bool addEos, int32_t *outTokens, int32_t maxTokens) |
Encode text to tokens using a TinyLLMAsset's tokenizer.
| model | TinyLLMAsset pointer |
| text | Text to encode |
| addBos | Add BOS token |
| addEos | Add EOS token |
| outTokens | Output buffer for tokens (caller allocates) |
| maxTokens | Size of output buffer |
| void(* PolyphaseEngineAPI::UnloadAsset) (const char *name) |
Unload an asset by name.
| name | Asset name to unload |