public static void Initialize()
{
// only need to initialize once
if ( !isInitialized )
{
string syntax = "";
// flags for which of the programs use finite extrusion
bool[] vertexProgramFinite =
new bool[] { false, false, false, false, true, true, true, true };
// flags for which of the programs use debug rendering
bool[] vertexProgramDebug =
new bool[] { false, true, false, true, false, true, false, true };
// types of lights that each of the programs target
LightType[] vertexProgramLightTypes =
new LightType[] {
LightType.Point, LightType.Point,
LightType.Directional, LightType.Directional,
LightType.Point, LightType.Point,
LightType.Directional, LightType.Directional
};
// load hardware extrusion programs for point & dir lights
if ( GpuProgramManager.Instance.IsSyntaxSupported( "arbvp1" ) )
{
syntax = "arbvp1";
}
else if ( GpuProgramManager.Instance.IsSyntaxSupported( "vs_1_1" ) )
{
syntax = "vs_1_1";
}
else
{
throw new AxiomException( "Vertex programs are supposedly supported, but neither arbvp1 nor vs_1_1 syntaxes are supported." );
}
// create the programs
for ( int i = 0; i < programNames.Length; i++ )
{
// sanity check to make sure it doesn't already exist
if ( GpuProgramManager.Instance.GetByName( programNames[ i ] ) == null )
{
string source = ShadowVolumeExtrudeProgram.GetProgramSource( vertexProgramLightTypes[ i ], syntax, vertexProgramFinite[ i ], vertexProgramDebug[ i ] );
// create the program from the static source
GpuProgram program = GpuProgramManager.Instance.CreateProgramFromString( programNames[ i ], ResourceGroupManager.InternalResourceGroupName, source, GpuProgramType.Vertex, syntax );
// load the program
program.Load();
}
}
isInitialized = true;
}
}