Loading Prototypes

You may need to create instances of your prototypes by coding. To create instances of your prototypes, you must first load them. You can load a whole prototype library and then load one or more of the prototypes it contains. To do this, create an instance of the IlvProtoLibrary class and call its load method:

IlvProtoLibrary* lib = new IlvProtoLibrary(display, "mylib");

if(!lib->load())

IlvFatalError("Could not load prototype library");

If you want to load a prototype library that is not located in the display path, you can specify the directory where the library is located in the call to the constructor:

IlvProtoLibrary* lib = new IlvProtoLibrary(display, "mylib",

"/usr/somewhere/protos");

if(!lib->load())

IlvFatalError("Could not load prototype library");

Once you have loaded a prototype library, you can retrieve all its prototypes or a particular prototype with the following methods:

IlUInt count;

IlvPrototype** protos = lib->getPrototypes(count);

or:

IlvPrototype* proto = lib->getPrototype("myproto");

The array returned by the getPrototypes method is allocated with the new[] operator and must be released with the delete[] operator when it is no longer needed.

Alternatively, you can load each prototype individually with the global function IlvLoadPrototype:

IlvPrototype* proto = IlvLoadPrototype("mylib.myproto", display);

The first argument specifies the name of the prototype library and the name of the prototype (separated by a period). The second argument is the instance of IlvDisplay that your application has created. The prototype library file and the prototype files are searched for in the file system using the display path.