Extension

<dmsdk/extension/extension.h>

Functions for creating and controlling engine native extension libraries.

DM_DECLARE_EXTENSION

declare a new 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.

PARAMETERS

symbol -

symbol external extension symbol description (no quotes).

name -

const char* extension name. Human readable.

appinit -

function(dmExtension::AppParams* app_params) app-init function. May be null.

app_params
dmExtension::AppParams* Pointer to an AppParams structure.

appfinal -

function(dmExtension::AppParams* app_params) app-final function. May be null.

app_params
dmExtension::AppParams* Pointer to an AppParams structure.

init -

function(dmExtension::Params* params) init function. May not be null.

params
dmExtension::Params* Pointer to a Params structure

update -

function(dmExtension::Params* params) update function. May be null.

params
dmExtension::Params* Pointer to a Params structure

on_event -

function(dmExtension::Params* params, const dmExtension::Event* 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(dmExtension::Params* params) 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

Set if the platform is Android


DM_PLATFORM_HTML5

Set if the platform is Html5

Set if the platform is Html5


DM_PLATFORM_IOS

Set if the platform is iPhoneOS

Set if the platform is iPhoneOS


DM_PLATFORM_LINUX

Set if the platform is Linux

Set if the platform is Linux


DM_PLATFORM_OSX

Set if the platform is OSX

Set if the platform is OSX


DM_PLATFORM_WINDOWS

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

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


OnActivityResult

OnActivityResult callback typedef

Activity result callback function type. Monitors events from the main activity. Used with RegisterOnActivityResultListener() and UnregisterOnActivityResultListener()

PARAMETERS

env -

void*

activity -

void*

request_code -

int32_t

result_code -

int32_t

result -

void*


RegisterAndroidOnActivityResultListener()

register Android activity result callback

Registers an activity result callback. Multiple listeners are allowed.

PARAMETERS

[type:dmExtension::OnActivityResult] -

listener


RegisteriOSUIApplicationDelegate()

Register application delegate

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

This function is only available on iOS.

PARAMETERS

delegate -

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

EXAMPLES

```objective-c

// myextension_ios.mm

id g_MyApplicationDelegate;


UnregisterAndroidOnActivityResultListener()

unregister Android activity result callback

Unregisters an activity result callback

PARAMETERS

[type:dmExtension::OnActivityResult] -

listener


UnregisteriOSUIApplicationDelegate()

Unregister an application delegate

Deregister a previously registered iOS application delegate

This function is only available on iOS.

PARAMETERS

delegate -

an id

EXAMPLES

// myextension_ios.mm
void ExtensionAppFinalizeiOS(dmExtension::AppParams* params)
{
    dmExtension::UnregisteriOSUIApplicationDelegate(g_MyApplicationDelegate);
    [g_MyApplicationDelegate release];
    g_MyApplicationDelegate = 0;
}


dmExtension::AppParams()

application level callback data

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

MEMBERS

m_ConfigFile -

dmConfigFile::HConfig


dmExtension::Event()

event callback data

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

MEMBERS

m_Event -

dmExtension::EventID


dmExtension::EventID

event id enumeration

Event id enumeration.

MEMBERS

dmExtension::EVENT_ID_ACTIVATEAPP -

dmExtension::EVENT_ID_DEACTIVATEAPP -


dmExtension::Params()

extension level callback data

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

MEMBERS

m_ConfigFile -

dmConfigFile::HConfig

m_L -

lua_State*


dmExtension::Result

result enumeration

Result enumeration.

MEMBERS

dmExtension::RESULT_OK -

dmExtension::RESULT_INIT_ERROR -