Main Page   Modules   Alphabetical List   Data Structures   Data Fields  

Serializing Name Data
[Tutorial 4 - Writing a Plugin]

To complete our simple plugin we would like to write the names of atomics into .DFF files, and read the data back again. RenderWare Graphics provides hooks to make this very easy. All that our plugin has to do is to inform RenderWare Graphics that we have data that we would like to write to (or read from) the .DFF stream, and provide the code to actually perform the reading and writing. When RenderWare Graphics reads in a .DFF it uses chunk identifiers to determine what data is stored in the file. Being able to identify the data helps RenderWare Graphics locate a callback function to read the data. This is why having unique plugin IDs (that also serve as the chunk ID) is so important.

To support reading and writing our plugin data to streams, we must first inform RenderWare Graphics that we can serialize data. The RpAtomicRegisterPluginStream() API call is used for this purpose. In addition to the unique plugin ID, we also pass to this function three function pointers. These are the read, write, and sizing callbacks. The read and write functions will be called to serialize the plugin data, and the sizing callback is used to tell RenderWare Graphics how many bytes will be read from/written to the stream. Note that the number of bytes might differ from the size of the extension data. In our tutorial we store only a single character pointer, however the number of bytes that we serialize to disk will depend on the size of the string stored within the atomic.

Next...
Criterion Software © 1993-2004 Criterion Software Limited. All rights reserved. Built Thu Feb 12 13:46:59 2004. Send Feedback