Often, the data you are submitting to IwGx is being rewritten at every call to your render function. You might want to create a stream or material on the stack. This is not permitted, as the data submitted to IwGx must persist until IwGxFlush() is called at the end of your application render loop.
IwGx has a data cache which is reset at the end of each call to IwGxFlush(). You can freely allocate data from this cache during the render loop, and submit it to IwGx. You do not need to delete it, it is effectively lost when the cache is reset at the next call to IwGxFlush().
Use IW_GX_ALLOC() to allocate data from the cache. For example:
Objects allocated from the data cache using IW_GX_ALLOC() will not have gone any initialisation; for example, class constructors will not have been called. It is therefore suitable only for classes with default constructors.
To allocate and initialise (call the constructors for) an array of objects, use IW_GX_ALLOC_OBJECTS(). Pass in "1" if allocating and initialising only a single object.
Note: Objects allocated on the data cache will never have any destructors called. CIwMaterial knows whether it has been allocated on the cache, and ensures that any further allocations attached to the object are also allocated from the data cache. Be very careful when allocating other types of object from the data cache.
Materials and geometry streams sent to IwGx must persist to the end of the render loop (when IwGxFlush() is called). To re-iterate: it is not permitted to create geometry streams on the stack, as the data may be destroyed before IwGxFlush() is called.
The size of the data cache can be set within the ICF file, for example:
Note: If the user overflows the data cache (tries to allocate too much data from the cache between calls to IwGxFlush()), an assertion will fire.