Axiom.Graphics.GpuProgramParameters.GetNamedIntConstant C# (CSharp) Method

GetNamedIntConstant() public method

Gets a Named Int Constant entry if the name is found otherwise returns a null.
public GetNamedIntConstant ( string name ) : IntConstantEntry
name string Name of the constant to retreive.
return IntConstantEntry
		public IntConstantEntry GetNamedIntConstant( string name )
		{
			int index;
			if ( namedParams.TryGetValue(name, out index) )
			{
				return GetIntConstant( index );
			}
			return null;
		}

Usage Example

        /// <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
                        }
                    }
                }
            }
        }