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