Sdk extension api documentation

Functions for creating and controlling engine native extension libraries.

Namespace: dmExtension
Include: #include <dmsdk/extension/extension.h>
TYPES
extension_callback_t Extra extension callback typedef
ENUMS
dmExtension::CallbackType extra callback enumeration
dmExtension::EventID event id enumeration
dmExtension::Result result enumeration
STRUCTS
struct dmExtension::AppParams application level callback data
struct dmExtension::Event event callback data
struct dmExtension::Params extension level callback data
FUNCTIONS
bool RegisterCallback(CallbackType callback_type, extension_callback_t func) Register extra extension callbacks.
void RegisteriOSUIApplicationDelegate(id delegate) Register application delegate
void UnregisteriOSUIApplicationDelegate( delegate) Unregister an application delegate
MACROS
DM_DECLARE_EXTENSION(symbol, name, appinit, appfinal, init, update, on_event, final) declare a new extension
DM_PLATFORM_ANDROID() Set if the platform is Android
DM_PLATFORM_HTML5() Set if the platform is Html5
DM_PLATFORM_IOS() Set if the platform is iPhoneOS
DM_PLATFORM_LINUX() Set if the platform is Linux
DM_PLATFORM_OSX() Set if the platform is OSX
DM_PLATFORM_WINDOWS() Set if the platform is Windows (on both x86 and x86_64)

Functions

RegisterCallback

bool RegisterCallback(CallbackType callback_type, extension_callback_t func)

Register extra extension callbacks.

PARAMETERS

CallbackType callback_type Callback type enum
extension_callback_t func Function to register as callback

RETURNS

bool Returns true if successfully registered the function, false otherwise.

RegisteriOSUIApplicationDelegate

void RegisteriOSUIApplicationDelegate(id delegate)

Register an iOS application delegate to the engine. Multiple delegates are supported (Max 32)

PARAMETERS

id delegate An UIApplicationDelegate, see: https://developer.apple.com/documentation/uikit/uiapplicationdelegate?language=objc

EXAMPLES

```objective-c // myextension_ios.mm id g_MyApplicationDelegate;

UnregisteriOSUIApplicationDelegate

void UnregisteriOSUIApplicationDelegate( delegate)

Deregister a previously registered iOS application delegate This function is only available on iOS.

PARAMETERS

delegate an id

Structs

dmExtension::AppParams

TYPE

struct dmExtension::AppParams

Extension application entry callback data. This is the data structure passed as parameter by extension Application entry callbacks (AppInit and AppFinalize) functions

MEMBERS

dmConfigFile::HConfig m_ConfigFile
dmWebServer::HServer m_WebServer Only valid in debug builds, where the engine service is running. 0 otherwise.


dmExtension::Event

TYPE

struct dmExtension::Event

Extension event callback data. This is the data structure passed as parameter by extension event callbacks (OnEvent)

MEMBERS

dmExtension::EventID m_Event


dmExtension::Params

TYPE

struct dmExtension::Params

Extension callback data. This is the data structure passed as parameter by extension callbacks (Init, Finalize, Update, OnEvent)

MEMBERS

dmConfigFile::HConfig m_ConfigFile the config file
dmResource::HFactory m_ResourceFactory the resource factory
lua_State* m_L the lua state


Types

extension_callback_t

Callback typedef for functions passed to RegisterCallback().


Enums

dmExtension::CallbackType

Extra callback enumeration for RegisterCallback function.

dmExtension::CALLBACK_PRE_RENDER
dmExtension::CALLBACK_POST_RENDER

dmExtension::EventID

Event id enumeration. EVENT_ID_ICONIFYAPP and EVENT_ID_DEICONIFYAPP only available on

dmExtension::EVENT_ID_ACTIVATEAPP
dmExtension::EVENT_ID_DEACTIVATEAPP
dmExtension::EVENT_ID_ICONIFYAPP
dmExtension::EVENT_ID_DEICONIFYAPP

dmExtension::Result

Result enumeration.

dmExtension::RESULT_OK
dmExtension::RESULT_INIT_ERROR

Macros

DM_DECLARE_EXTENSION

Declare and register new extension to the engine. This macro is used to declare the extension callback functions used by the engine to communicate with the extension.

symbol external extension symbol description (no quotes).
name extension name. Human readable.
appinit app-init function. May be null.
app_params
dmExtension::AppParams* Pointer to an AppParams structure.
appfinal app-final function. May be null.
app_params
dmExtension::AppParams* Pointer to an AppParams structure.
init init function. May not be null.
params
dmExtension::Params* Pointer to a Params structure
update update function. May be null.
params
dmExtension::Params* Pointer to a Params structure
on_event event callback function. May be null.
params
dmExtension::Params* Pointer to a Params structure
event
dmExtension::Event* const Pointer to an Event structure
final function. May not be null.
params
dmExtension::Params* Pointer to an Params structure.

EXAMPLES

Register a new extension:
DM_DECLARE_EXTENSION(MyExt, "MyExt", AppInitializeMyExt, AppFinalizeMyExt, InitializeMyExt, UpdateMyExt, OnEventMyExt, FinalizeMyExt);

DM_PLATFORM_ANDROID

Set if the platform is Android


DM_PLATFORM_HTML5

Set if the platform is Html5


DM_PLATFORM_IOS

Set if the platform is iPhoneOS


DM_PLATFORM_LINUX

Set if the platform is Linux


DM_PLATFORM_OSX

Set if the platform is OSX


DM_PLATFORM_WINDOWS

Set if the platform is Windows (on both x86 and x86_64)