Functions for creating and controlling engine native extension libraries.
Namespace: | Extension |
Include: | #include <dmsdk/extension/extension.h> |
TYPES | |
---|---|
FExtensionAppInitialize | Callback when the app is being initialized. Called... |
FExtensionCallback | Extra extension callback typedef |
FExtensionFinalize | Calls for the finalization of an extension |
FExtensionInitialize | Callback when the app is being finalized |
FExtensionInitialize | Callback after all extensions have been called wit... |
FExtensionOnEvent | Receives an event from the engine |
FExtensionUpdate | Updates an extension. Called for each game frame. |
CONSTANTS | |
---|---|
ExtensionDescBufferSize | Used when registering new extensions |
ENUMS | |
---|---|
ExtensionCallbackType | extra callback type |
ExtensionEventID | event id enumeration |
ExtensionResult | result enumeration |
STRUCTS | |
---|---|
struct ExtensionParams | The global parameters avalable when registering an... |
MACROS | |
---|---|
DM_DECLARE_EXTENSION(symbol, name, app_init, app_final, 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) |
void ExtensionAppParamsFinalize(ExtensionAppParams* app_params)
Finalizes an extension app params struct (deallocates internal memory)
PARAMETERS
ExtensionAppParams* |
app_params |
the params |
void* ExtensionAppParamsGetContext(ExtensionAppParams params, dmhash_t name_hash)
Gets a context using a specified name hash
PARAMETERS
ExtensionAppParams |
params |
the params |
dmhash_t |
name_hash |
the context name hash |
RETURNS
void* |
The context, if it exists |
void* ExtensionAppParamsGetContextByName(ExtensionAppParams params, const char* name)
Gets a context using a specified name
PARAMETERS
ExtensionAppParams |
params |
the params |
const char* |
name |
the context name |
RETURNS
void* |
The context, if it exists |
void ExtensionAppParamsInitialize(ExtensionAppParams* app_params)
Initializes an extension app params struct NOTE: this is an opaque struct, do not use it's members directly!
PARAMETERS
ExtensionAppParams* |
app_params |
the params |
int ExtensionAppParamsSetContext(ExtensionAppParams params, const char* name, void* context)
Sets a context using a specified name
PARAMETERS
ExtensionAppParams |
params |
the params |
const char* |
name |
the context name |
void* |
context |
the context |
RETURNS
int |
0 if successful |
void ExtensionParamsFinalize(ExtensionParams* app_params)
Finalizes an extension params struct (deallocates internal memory)
PARAMETERS
ExtensionParams* |
app_params |
the params |
void* ExtensionParamsGetContext(ExtensionParams params, dmhash_t name_hash)
Gets a context using a specified name hash
PARAMETERS
ExtensionParams |
params |
the params |
dmhash_t |
name_hash |
the context name hash |
RETURNS
void* |
The context, if it exists |
void* ExtensionParamsGetContextByName(ExtensionParams params, const char* name)
Gets a context using a specified name
PARAMETERS
ExtensionParams |
params |
the params |
const char* |
name |
the context name |
RETURNS
void* |
The context, if it exists |
void ExtensionParamsInitialize(ExtensionParams* app_params)
Initializes an extension params struct NOTE: this is an opaque struct, do not use it's members directly!
PARAMETERS
ExtensionParams* |
app_params |
the params |
int ExtensionParamsSetContext(ExtensionAppParams params, const char* name, void* context)
Sets a context using a specified name
PARAMETERS
ExtensionAppParams |
params |
the params |
const char* |
name |
the context name |
void* |
context |
the context |
RETURNS
int |
0 if successful |
void ExtensionRegister(void* desc, const char* desc_size, const char* name, FExtensionAppInitialize app_initialize, FExtensionAppFinalize app_finalize, FExtensionInitialize initialize, FExtensionFinalize finalize, FExtensionUpdate update, FExtensionOnEvent on_event)
Extension declaration helper. Internal function. Use DM_DECLARE_EXTENSION
PARAMETERS
void* |
desc |
A persistent buffer of at least 128 bytes. |
const char* |
desc_size |
size of buffer holding desc. in bytes |
const char* |
name |
extension name. human readble. max 16 characters long. |
FExtensionAppInitialize |
app_initialize |
app-init function. May be null |
FExtensionAppFinalize |
app_finalize |
app-final function. May be null |
FExtensionInitialize |
initialize |
init function. May not be 0 |
FExtensionFinalize |
finalize |
finalize function. May not be 0 |
FExtensionUpdate |
update |
update function. May be null |
FExtensionOnEvent |
on_event |
event callback function. May be null |
void ExtensionRegisteriOSUIApplicationDelegate(id
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
// myextension_ios.mm
id<UIApplicationDelegate> g_MyApplicationDelegate;
\@interface MyApplicationDelegate : NSObject <UIApplicationDelegate>
- (void) applicationDidBecomeActive:(UIApplication *) application;
\@end
\@implementation MyApplicationDelegate
- (void) applicationDidBecomeActive:(UIApplication *) application {
dmLogWarning("applicationDidBecomeActive - MyAppDelegate");
}
\@end
struct MyAppDelegateRegister
{
MyApplicationDelegate* m_Delegate;
MyAppDelegateRegister() {
m_Delegate = [[FacebookAppDelegate alloc] init];
Extension::RegisteriOSUIApplicationDelegate(m_Delegate);
}
~MyAppDelegateRegister() {
Extension::UnregisteriOSUIApplicationDelegate(m_Delegate);
[m_Delegate release];
}
};
MyAppDelegateRegister g_FacebookDelegateRegister;
void ExtensionUnregisteriOSUIApplicationDelegate(void* delegate)
Deregister a previously registered iOS application delegate This function is only available on iOS.
PARAMETERS
void* |
delegate |
an id |
TYPE
struct ExtensionParams
The global parameters avalable when registering and unregistering an extensioin
MEMBERS
HConfigFile |
m_ConfigFile |
The game project settings (including overrides and plugins) |
HResourceFactory |
m_ResourceFactory |
The game resource factory / repository |
lua_State* |
m_L |
The Lua state. |
Used when registering new extensions
Callback when the app is being initialized. Called before FExtensionInitialize
Callback typedef for functions passed to RegisterCallback().
Calls for the finalization of an extension
Callback when the app is being finalized
Callback after all extensions have been called with FExtensionAppInitialize
Receives an event from the engine
Updates an extension. Called for each game frame.
Extra callback type for RegisterCallback function.
EXTENSION_CALLBACK_PRE_RENDER |
|
EXTENSION_CALLBACK_POST_RENDER |
Event id enumeration. EVENT_ID_ICONIFYAPP and EVENT_ID_DEICONIFYAPP only available on
EXTENSION_EVENT_ID_ACTIVATEAPP |
|
EXTENSION_EVENT_ID_DEACTIVATEAPP |
|
EXTENSION_EVENT_ID_ICONIFYAPP |
|
EXTENSION_EVENT_ID_DEICONIFYAPP |
|
EXTENSION_EVENT_ID_ENGINE_INITIALIZED |
|
EXTENSION_EVENT_ID_ENGINE_DELETE |
Result enumeration.
EXTENSION_RESULT_OK |
|
EXTENSION_RESULT_INIT_ERROR |
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. |
app_init |
app-init function. May be null.
|
app_final |
app-final function. May be null.
|
init |
init function. May not be null.
|
update |
update function. May be null.
|
on_event |
event callback function. May be null.
|
final |
function. May not be null.
|
EXAMPLES
Register a new extension:DM_DECLARE_EXTENSION(MyExt, "MyExt", AppInitializeMyExt, AppFinalizeMyExt, InitializeMyExt, UpdateMyExt, OnEventMyExt, FinalizeMyExt);
Set if the platform is Android
Set if the platform is Html5
Set if the platform is iPhoneOS
Set if the platform is Linux
Set if the platform is OSX
Set if the platform is Windows (on both x86 and x86_64)