public static GetProgramSource ( LightType lightType, string syntax, bool finite, bool debug ) : string | ||
lightType | LightType | Type of light to get the source for. |
syntax | string | Syntax code of interest. |
finite | bool | Is this for finite volume extrusion? |
debug | bool | Should the shadow volumes be visible? |
return | string |
public static string GetProgramSource( LightType lightType, string syntax, bool finite, bool debug )
{
if ( lightType == LightType.Directional )
{
if ( syntax == "arbvp1" )
{
if ( finite )
{
if ( debug )
{
return dirArbvp1FiniteDebug;
}
else
{
return dirArbvp1Finite;
}
}
else
{
if ( debug )
{
return dirArbvp1Debug;
}
else
{
return dirArbvp1;
}
}
}
else
{
if ( finite )
{
if ( debug )
{
return dirVs_1_1FiniteDebug;
}
else
{
return dirVs_1_1Finite;
}
}
else
{
if ( debug )
{
return dirVs_1_1Debug;
}
else
{
return dirVs_1_1;
}
}
}
}
else
{
if ( syntax == "arbvp1" )
{
if ( finite )
{
if ( debug )
{
return pointArbvp1FiniteDebug;
}
else
{
return pointArbvp1Finite;
}
}
else
{
if ( debug )
{
return pointArbvp1Debug;
}
else
{
return pointArbvp1;
}
}
}
else
{
if ( finite )
{
if ( debug )
{
return pointVs_1_1FiniteDebug;
}
else
{
return pointVs_1_1Finite;
}
}
else
{
if ( debug )
{
return pointVs_1_1Debug;
}
else
{
return pointVs_1_1;
}
}
}
}
}
/// <summary> /// Initialize the creation of these core vertex programs. /// </summary> 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], source, GpuProgramType.Vertex, syntax); // load the program program.Load(); } } isInitialized = true; } }