Core Library
SRT files can be loaded by the CCore class either by passing the SDK a filename or memory block. The memory block version expects a pointer to a block that’s essentially a binary SRT file read into a buffer. The Core library includes the utility function, LoadFileIntoBuffer(), that will read an SRT file and return a memory buffer that will work with LoadTree().
Note: When passing a memory block into the SDK, you must specify ownership of the block. To minimize the number of heap allocations that occur on load, the SDK can simply use offsets into the provided memory block as geometry references. The tradeoff using this approach is that the memory block cannot be deleted until after CCore::DeleteGeometry() is called. Alternatively, you can instruct the SDK to make an internal copy of the buffer after which its management will be handled automatically, freeing the application from restrictions on its own copy of the buffer. Traditionally, console developers will choose to manage the buffer directly. |
---|
The following example demonstrates how to read an SRT file and retrieve some of its data. Once the load is complete, all of the SRT data is immediately available.
<}
Note the error handling code. If an error occurs within the Core library, it will try to provide some explanation for the failure via the CCore::GetError() function. If you are evaluating or leasing SpeedTree and your key expired, the LoadTree() call will always fail and return the expiration date via the error string.
More on the SDK's ystem.htm“>error system.
Note: Once you've scanned or copied the geometry and materials, it can be deleted using CCore::DeleteGeometry(), leaving the rest of the CCore object intact. DeleteGeometry() will free about 85-90% of SRT file size from the heap. |
---|