Macros used for tagging blocks of code for the `generate-graph-nodes` utility.
`generate-graph-nodes` searches all files matching the pattern `*graph_nodes*.c`for these macros
and generates interface code for all functions inside a `GGN_BEGIN/GGN_END` macro pair. This
interface code is generated into an `*.inl` file with the same name as the original file, and is
usually included in the `*.c` file with an `#include` directive.
The additional macros in this file can be used to further specify how functions and parameters
should be interpreted by the graph system. For example, you can mark parameters as optional, give
them custom types and names, etc. These macros apply to the next node function only (i.e. they
static inline void sample_float_square(float a, float *res)
*res = a * a;
TM_DLL_EXPORT void tm_load_plugin(struct tm_api_registry_api *reg, bool load)
// This is auto generated from the graph node generator, you just need to call it.
Begins a new block of functions to be exposed to the graph interpreter.
For each function in the block, a `*_node_f` function wrapper will be generated that converts
graph wire data to the parameter types expected by the function. In addition, a
struct will be generated that describes the node.
The block is ended by the `GGN_END()`
macro. All the nodes in the block will be given the
If you want nodes with different categories in the same `.c` file, you should use multiple
Ends a node definition block started by `GGN_BEGIN()`
If this macro is used inside any `GGN_BEGIN/GGN_END` block, a function for registering all the
nodes in the file with the API registry will automatically be generated. The name of the function
will be `generated__register_<FILENAME>`.
The `GGN_NODE_QUERY()` macro marks this node as a Query node. Query nodes are triggered
automatically when their output is requested. Nodes that aren't query nodes need to be triggered
by an explicit event.
Generated nodes will by default have the same name as the function that implements them.
Using this macro before the node definition will give the node a different "display name" --
i.e. the name that will be shown for the node in the graph editor.
The node will still use the function name in the save files.
Note that changing the "display name" of a node is harmless, but changing its actual name
(the name of the function) will break compatibility with old save files.
#define GGN_PARAM_TOOLTIP(parameter, tooltip)
Specifies a toolip associated with the `parameter`. The macro automatically adds
around your text.
Specifies that `parameter` is optional.
#define GGN_PARAM_DEFAULT_VALUE(parameter, value)
Specify a default value for `parameter`. This default value will be used if an optional parameter
is not given an explicit value.
#define GGN_PARAM_EDIT_TYPE(parameter, type)
Specifies that `parameter` should be considered to be of `type` in the editor.
This is used when you want to give the graph editor more information about the parameter's `type`
than what is available from the parameter type in the function definition. As an example, a
can represent either a *position* or a *scale*. Using:
Clarifies that we are taking about a `TM_TT_TYPE__POSITION`
parameter. (`TM_TT_TYPE_` is
automatically prepended to the type specified with `GGN_PARAM_EDIT_TYPE`.)
#define GGN_PARAM_CONNECTOR(parameter, connector)
Specifies the display name for the `parameter`s connector.
By default, the text shown on the connector will be the same as the name of the parameter, but
sometimes you may want to use a different name:
GGN_PARAM_CONNECTOR(true_res, "true res");
GGN_PARAM_CONNECTOR(false_res, "false res");
static inline void bool_to_float(bool b, float true_res, float false_res, float *res)
In this case we can't give the parameters the name `bool` or `true res`, because they are not
valid C identifiers, but by using the `GGN_PARAM_CONNECTOR()`
macro we can ensure that the
connectors still get the desired names.