Documentation

SpeedTree Runtime SDK

Version: 10

SpeedTree Runtime SDK

Version: 10

Initialization

A CForestRI (RI stands for Render Interface) object cannot be instantiated by itself.
Read time 1 minuteLast updated 2 hours ago

CForestRI is essentially a shell, making graphics calls in the correct sequence, but has no knowledge of any particular graphics system. It is given this knowledge using template parameters. These parameters are known as policy classes (a concept introduced by Andrei Alexandrescu in his 2001 book Modern C++ Design), and they fill out the implementations of the class interfaces defined by
CForestRI
. Objects like
CTextureRI
,
CRenderStateRI
, and
CGeometryBufferRI
provide the necessary functionality for the Render Interface classes to carry out a full scene render. This technique enables client applications to replace any of the default SpeedTree implementations without changing the Runtime SDK library source.
There are dozens of configurable parameters for the
CForestRI
object and most are stored in the
SForestRenderInfo
structure. Example parameters include the shader filename, fogging data, lighting parameters, shadow values, and more. Once these have been set using
CForestRI::SetRenderInfo()
, the graphics system is ready to be initialized.
CForestRI::InitGfx()
is the main initialization function that builds vertex buffers, loads the shaders, sets up wind, loads textures, etc. After it is complete, the object is ready to manage rendering chores. See the reference application for an easy to follow example of how to set this up (but keep in mind that the code gets a little long with all the command-line options being used to call almost every possible configuration function).
Note
Once the
CForestRI
object has been initialized, whatever flags were used for setting wind, grass, and terrain support cannot be changed.