The Main Entry Function

// forward declarations
static OfxStatus render(OfxImageEffectHandle  instance, OfxPropertySetHandle inArgs, OfxPropertySetHandle outArgs);
static OfxStatus describe(OfxImageEffectHandle effect);
static OfxStatus onLoad(void);
static OfxStatus describeInContext( OfxImageEffectHandle  effect,  OfxPropertySetHandle inArgs)

// The main entry point function
static OfxStatus
pluginMain(const char *action,  const void *handle, OfxPropertySetHandle inArgs,  OfxPropertySetHandle outArgs)
  // cast to appropriate type
  OfxImageEffectHandle effect = (OfxImageEffectHandle) handle;

  // called as the very first action before any other
  if(strcmp(action, kOfxActionLoad) == 0) {
    return onLoad();
  // called to describe the plug-in
  else if(strcmp(action, kOfxActionDescribe) == 0) {
    return describe(effect);
  // called to describe the plug-in in a given context
  else if(strcmp(action, kOfxImageEffectActionDescribeInContext) == 0) {
    return describeInContext(effect, inArgs);
  // called to render a frame
  else if(strcmp(action, kOfxImageEffectActionRender) == 0) {
    return render(effect, inArgs, outArgs);
  // all other actions return the default value
  return kOfxStatReplyDefault;

The pluginMain was passed to the host int the OfxPlugin struct returned by OfxGetPlugin . This function is where the host tells the plug-in what it needs to do. You will note that the actions passed to the plug-in are encoded as strings. This makes actions easily extensible whilst minimising the chances of name clashing.

The function also takes a "handle" argument. This handle is the thing the action must be performed on. In this case, as we are an image effect, the handle must be cast to an OfxImageEffectHandle , which is simply a blind pointer to some host data representing an image effect.

The last two parameters inArgs and outArgs are used to pass in arguments for the specific action. These are encapsulated via blind property sets. The inArgs are extra arguments the action will need to do its job, whilst outArgs are for things the plug-in will need to set to do its action.

Our main entry only traps four of the many possible actions. The actual actions will be described below.