- Select ref document -

SDK Extension API documentation

version 1.2.144

<dmsdk/extension/extension.h>

Functions for creating and controlling engine native extension libraries.

Functions

RegisterAndroidOnActivityResultListener

RegisterAndroidOnActivityResultListener([type:OnActivityResult])

Registers an activity result callback. Multiple listeners are allowed.

Parameters

[type:OnActivityResult]

listener

[type:OnActivityResult]

listener

RegisteriOSUIApplicationDelegate

RegisteriOSUIApplicationDelegate(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

delegate

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

Examples

```cpp

// myextension_ios.mm

id g_MyApplicationDelegate;

UnregisterAndroidOnActivityResultListener

UnregisterAndroidOnActivityResultListener([type:OnActivityResult])

Unregisters an activity result callback

Parameters

[type:OnActivityResult]

listener

[type:OnActivityResult]

listener

UnregisteriOSUIApplicationDelegate

UnregisteriOSUIApplicationDelegate(delegate)

Deregister a previously registered iOS application delegate

This function is only available on iOS.

Parameters

delegate

an id

delegate

an id

Examples

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

Macros

DM_DECLARE_EXTENSION

DM_DECLARE_EXTENSION(symbol, name, appinit, appfinal, init, update, on_event, final)

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.
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

DM_PLATFORM_ANDROID()

Set if the platform is Android

DM_PLATFORM_HTML5

DM_PLATFORM_HTML5()

Set if the platform is Html5

DM_PLATFORM_IOS

DM_PLATFORM_IOS()

Set if the platform is iPhoneOS

DM_PLATFORM_LINUX

DM_PLATFORM_LINUX()

Set if the platform is Linux

DM_PLATFORM_OSX

DM_PLATFORM_OSX()

Set if the platform is OSX

DM_PLATFORM_WIN32

DM_PLATFORM_WIN32()

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

Structs

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

m_ConfigFile

dmConfigFile::HConfig

m_ConfigFile

dmConfigFile::HConfig

dmExtension::Event

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

Members

m_Event

dmExtension::EventID

m_Event

dmExtension::EventID

dmExtension::Params

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*

m_ConfigFile

dmConfigFile::HConfig

m_L

lua_State*

Typedefs

OnActivityResult

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*

env

void*

activity

void*

request_code

int32_t

result_code

int32_t

result

void*

Enumerations

dmExtension::EventID

Event id enumeration.

Members

dmExtension::EVENT_ID_ACTIVATEAPP
dmExtension::EVENT_ID_DEACTIVATEAPP
dmExtension::EVENT_ID_ACTIVATEAPP
dmExtension::EVENT_ID_DEACTIVATEAPP

dmExtension::Result

Result enumeration.

Members

dmExtension::RESULT_OK
dmExtension::RESULT_INIT_ERROR
dmExtension::RESULT_OK
dmExtension::RESULT_INIT_ERROR