Notification Callbacks

mi_api_notify_callback
miBoolean mi_api_notify_callback(
    void            (*cb)(char      *name,
                          miTag     tag,
                          miTag     phen_tag,
                          char      mode))

Install a notification callback function. Whenever API creates, recreates, or deletes a toplevel tag, the specified callback cb is called with the element name, the element tag, and a mode character that is 'c' for creation, 'i' for an incremental change, or 'd' for deletion. Toplevel tags are elements with persistent names such as objects, cameras, declarations, shaders etc. that have a name and a tag, but not bases or surfaces (which are not at the top level but encapsulated in objects, so their names are lost when the object definition is finished). If the element is created or modified in phenomenon scope, the tag of the enclosing phenomenon is passed as phen_tag; otherwise phen_tag is a null tag.

More precisely, the callback is called for options, cameras, file output statements, instances, instance groups, lights, objects, materials, image textures, function declarations, phenomenon declarations, and named (but not anonymous) shaders.

The name may be a null pointer, and should be mi_mem_strdup'd if stored because it may be released or destroyed after the callback returns. Since API often creates hidden unnamed elements such as instances and instance groups for objects containing multiple object groups, sometimes no name is available. The callback is called when the element is created, not when API has finished filling it with parameters.

The main purpose of this callback is to let a caller who has read a sub-scene (probably after entering a scope, see below) delete it at a later time. To delete a scene element that caused a call to the notify callback, call mi_api_delete(name) if a nonzero name was passed, or call mi_scene_delete_one(tag) if the name was a null pointer. mi_api_delete calls mi_scene_delete_one and also removes the name from API's symbol tables. These delete functions will take care of unnamed sub-tags that did not cause calls to the notification callback. Do not call mi_scene_delete because that would also delete named subtags which did cause calls to the callback, which might then be deleted twice. Note that calls to mi_api_delete cause a call to the callback with mode 'd'.

mi_api_error_callback
miBoolean mi_api_error_callback(
    void            (*err_cb)(char *, int),
    void            (*warn_cb)(char *, int))

Install error and warning callbacks. Two functions must be passed that accept a string argument (the message) and an integer (the message code). Message codes are unique identifiers in the range 1..999 that are integrated into the raylib error message codes as the last three digits.

The API module will call the callback functions whenever an error or a warning occurs, with an appropriate message. The function may print the message to the terminal or elsewhere, together with useful context information such as the current file name and line number if available. If no callbacks are installed, they default to mi_nerror and mi_nwarning, respectively, with a second argument of "%s" to prevent evaluation of percent characters. Note that all API functions also return miFALSE or a null pointer or a similar failure indicator if the requested operation could not be performed, in addition to any warning or error messages.

Copyright © 1986, 2015 NVIDIA ARC GmbH. All rights reserved.