/// <summary>
        ///		Updates program object uniforms using data from GpuProgramParameters.
        ///		normally called by GLSLGpuProgram.BindParameters() just before rendering occurs.
        /// </summary>
        /// <param name="parameters">GPU Parameters to use to update the uniforms params.</param>
        public void UpdateUniforms(GpuProgramParameters parameters)
        {
            for(int i = 0; i < uniformReferences.Count; i++) {
                UniformReference uniformRef = (UniformReference)uniformReferences[i];

                GpuProgramParameters.FloatConstantEntry currentFloatEntry = null;
                GpuProgramParameters.IntConstantEntry currentIntEntry = null;

                if(uniformRef.isFloat) {
                    currentFloatEntry = parameters.GetNamedFloatConstant(uniformRef.name);

                    if(currentFloatEntry != null) {
                        if(currentFloatEntry.isSet) {
                            switch(uniformRef.elementCount) {
                                case 1:
                                    Gl.glUniform1fvARB(uniformRef.location, 1, currentFloatEntry.val);
                                    break;

                                case 2:
                                    Gl.glUniform2fvARB(uniformRef.location, 1, currentFloatEntry.val);
                                    break;

                                case 3:
                                    Gl.glUniform3fvARB(uniformRef.location, 1, currentFloatEntry.val);
                                    break;

                                case 4:
                                    Gl.glUniform4fvARB(uniformRef.location, 1, currentFloatEntry.val);
                                    break;
                            } // end switch
                        }
                    }
                }
                else {
                    currentIntEntry = parameters.GetNamedIntConstant(uniformRef.name);

                    if(currentIntEntry != null) {
                        if(currentIntEntry.isSet) {
                            switch(uniformRef.elementCount) {
                                case 1:
                                    Gl.glUniform1ivARB(uniformRef.location, 1, currentIntEntry.val);
                                    break;

                                case 2:
                                    Gl.glUniform2ivARB(uniformRef.location, 1, currentIntEntry.val);
                                    break;

                                case 3:
                                    Gl.glUniform3ivARB(uniformRef.location, 1, currentIntEntry.val);
                                    break;

                                case 4:
                                    Gl.glUniform4ivARB(uniformRef.location, 1, currentIntEntry.val);
                                    break;
                            } // end switch
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Binds params by index to the vp30 program.
        /// </summary>
        /// <param name="parms"></param>
        public override void BindParameters(GpuProgramParameters parms)
        {
            if (parms.HasFloatConstants)
            {
                for (int index = 0; index < parms.FloatConstantCount; index++)
                {
                    GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant(index);

                    if (entry.isSet)
                    {
                        // send the params 4 at a time
                        Gl.glProgramParameter4fvNV(programType, index, entry.val);
                    }
                }
            }
        }
        public override void BindParameters(GpuProgramParameters parms)
        {
            if (parms.HasFloatConstants)
            {
                for (int index = 0; index < parms.FloatConstantCount; index++)
                {
                    GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant(index);

                    if (entry.isSet)
                    {
                        // MONO: the 4fv version does not work
                        float[] vals = entry.val;
                        Gl.glProgramLocalParameter4fARB(programType, index, vals[0], vals[1], vals[2], vals[3]);
                    }
                }
            }
        }
        public override void BindParameters(GpuProgramParameters parms)
        {
            // program constants done internally by compiler for local
            if (parms.HasFloatConstants)
            {
                for (int index = 0; index < parms.FloatConstantCount; index++)
                {
                    GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant(index);

                    if (entry.isSet)
                    {
                        // send the params 4 at a time
                        Gl.glSetFragmentShaderConstantATI(Gl.GL_CON_0_ATI + index, entry.val);
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Binds named parameters to fp30 programs.
        /// </summary>
        /// <param name="parms"></param>
        public override void BindParameters(GpuProgramParameters parms)
        {
            if (parms.HasFloatConstants)
            {
                for (int index = 0; index < parms.FloatConstantCount; index++)
                {
                    string name = parms.GetNameByIndex(index);

                    if (name != null)
                    {
                        GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant(index);

                        // send the params 4 at a time
                        Gl.glProgramNamedParameter4fvNV(programId, name.Length, name, entry.val);
                    }
                }
            }
        }
        /// <summary>
        ///     Called to pass parameters to the Nvparse program.
        /// </summary>
        /// <param name="parms"></param>
        public override void BindParameters(GpuProgramParameters parms)
        {
            // Register combiners uses 2 constants per texture stage (0 and 1)
            // We have stored these as (stage * 2) + const_index
            if (parms.HasFloatConstants)
            {
                for (int index = 0; index < parms.FloatConstantCount; index++)
                {
                    GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant(index);

                    if (entry.isSet)
                    {
                        int combinerStage = Gl.GL_COMBINER0_NV + (index / 2);
                        int pname         = Gl.GL_CONSTANT_COLOR0_NV + (index % 2);

                        // send the params 4 at a time
                        Gl.glCombinerStageParameterfvNV(combinerStage, pname, entry.val);
                    }
                }
            }
        }