/// <summary> /// Sets parameter used in a Cg program</summary> /// <param name="parameter">Name of parameter that we want to set</param> /// <param name="array">Float array as values that we want to set parameter with</param> /// <returns>True if parameter set successfully</returns> public static bool SetParameter(string parameter, float[] array) { if (array == null) { return(false); } IntPtr param; try { m_cg_parameters.TryGetValue(parameter, out param); if (param == (IntPtr)0) { return(false); } int length = array.Length; switch (length) { case 1: Cg.cgSetParameter1f(param, array[0]); break; case 2: Cg.cgSetParameter2f(param, array[0], array[1]); break; case 3: Cg.cgSetParameter3f(param, array[0], array[1], array[2]); break; case 4: Cg.cgSetParameter4f(param, array[0], array[1], array[2], array[3]); break; case 16: CgGl.cgGLSetMatrixParameterfc(param, array); break; default: break; } } catch { return(false); } return(true); }