/// <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;
            }
        }
コード例 #2
0
 /// <summary>
 ///    Load this usage (and ensure program is loaded).
 /// </summary>
 internal void Load()
 {
     // only load the program if it isn't already loaded
     if (!program.IsLoaded)
     {
         program.Load();
     }
 }
コード例 #3
0
        /// <summary>
        ///    Implementation of Resource.Load.
        /// </summary>
        protected override void LoadImpl()
        {
            if (IsSupported)
            {
                // polymorphic load
                LoadHighLevelImpl();

                // polymorphic creation of the low level program
                CreateLowLevelImpl();

                Debug.Assert(assemblerProgram != null, "Subclasses of HighLevelGpuProgram MUST initialize the low level assembler program.");

                // load the low level assembler program
                if (assemblerProgram != null)
                {
                    assemblerProgram.Load();
                    isLoaded = true;
                }
            }
        }