Example #1
0
        private void BindGpuProgramParameters(GpuProgramType type, Miyagi.Common.Resources.GpuProgram gpuProg)
        {
            if (gpuProg.NamedConstants.Count > 0)
            {
                using (GpuProgramParametersSharedPtr gpuParas = type == GpuProgramType.GPT_FRAGMENT_PROGRAM
                                                                                                                                        ? this.MogreRenderManager.Pass.GetFragmentProgramParameters()
                                                                                                                                        : this.MogreRenderManager.Pass.GetVertexProgramParameters())
                {
                    foreach (KeyValuePair <string, object> kvp in gpuProg.NamedConstants)
                    {
                        object o = kvp.Value;

                        if (o is ColourValue)
                        {
                            gpuParas.SetNamedConstant(kvp.Key, (ColourValue)o);
                        }
                        else if (o is int)
                        {
                            gpuParas.SetNamedConstant(kvp.Key, (int)o);
                        }
                        else if (o is float)
                        {
                            gpuParas.SetNamedConstant(kvp.Key, (float)o);
                        }
                        else if (o is Matrix4)
                        {
                            gpuParas.SetNamedConstant(kvp.Key, (Matrix4)o);
                        }
                        else if (o is Vector3)
                        {
                            gpuParas.SetNamedConstant(kvp.Key, (Vector3)o);
                        }
                        else if (o is Vector4)
                        {
                            gpuParas.SetNamedConstant(kvp.Key, (Vector4)o);
                        }
                    }

                    this.renderSystem.BindGpuProgramParameters(type, gpuParas, (ushort)GpuParamVariability.GPV_ALL);
                }
            }
        }
Example #2
0
        public override void CreateGpuProgram(Miyagi.Common.Resources.GpuProgram gpuProg)
        {
            if (!HighLevelGpuProgramManager.Singleton.ResourceExists(gpuProg.Name))
            {
                using (HighLevelGpuProgramPtr hlgp = HighLevelGpuProgramManager.Singleton.CreateProgram(
                           gpuProg.Name,
                           this.ResourceGroupName,
                           gpuProg.Language,
                           gpuProg.Type == Miyagi.Common.GpuProgramType.Fragment
                                                ? GpuProgramType.GPT_FRAGMENT_PROGRAM
                                                : GpuProgramType.GPT_VERTEX_PROGRAM))
                {
                    foreach (KeyValuePair <string, string> kvp in gpuProg.Parameters)
                    {
                        hlgp.SetParameter(kvp.Key, kvp.Value);
                    }

                    hlgp.SourceFile = gpuProg.SourceFile;
                    hlgp.Load();
                }
            }
        }