FrameBufferHandler ImageFilterHandler Classes Table of Contents

Global

Availability  LightWave® 6.0
Component  Layout, Modeler
Header  lwglobsrv.h

Global class plug-ins provide services that other plug-ins can use. They extend the list of globals that are part of the plug-in API.

Other plug-ins call your global class plug-in by calling the GlobalFunc with your server name as the first argument. LightWave® calls your activation function, which fills in the local->data field. This is then passed back to the caller as the return value of the GlobalFunc call.

Activation Function

The local argument to a global's activation function is an LWGlobalService.

   typedef struct st_LWGlobalService {
      const char *id;
      void       *data;
   } LWGlobalService;
id
The server name. This will be the same as the name field of the plug-in's server record. It's also the string that the requesting plug-in passed as the first argument to the GlobalFunc. If the module contains more than one global plug-in and they share a single activation function, the id can be used to tell which global is being requested.

data
The return value of the global. Fill this in with whatever is appropriate to satisfy the global request, or NULL to indicate failure. The value is typically a pointer to static data.

Global class plug-ins are available in both Modeler and Layout by default. If you don't want to run in one of these components, call the System ID global in your activation function and return AFUNC_BADAPP (or AFUNC_BADAPP_SILENT) if the LWSYS_TYPEBITS of the return value don't match a program you will run in. The following fragment will allow your global to be activated in Layout and Screamernet, but not in Modeler.

   unsigned int sysid, app;

   sysid = ( unsigned int ) global( LWSYSTEMID_GLOBAL,
      GFUSE_TRANSIENT );
   app = sysid & LWSYS_TYPEBITS;
   if ( app != LWSYS_LAYOUT && app != LWSYS_SCREAMERNET )
      return AFUNC_BADAPP;

Example

The vecmath sample is a Global class plug-in that provides a library of vector and matrix routines. Information on how to use this library in your plug-ins is given in the comments at the top of the source file.