Commits

Tobias Bohnen  committed 78f698a

* cleanup

  • Participants
  • Parent commits 21580b1

Comments (0)

Files changed (6)

 
         #endregion Delegates
 
+        #region Properties
+
+        #region Public Static Properties
+
+        public static CgErrorCallbackFuncDelegate ErrorCallback
+        {
+            get
+            {
+                return CgNativeMethods.cgGetErrorCallback();
+            }
+
+            set
+            {
+                CgNativeMethods.cgSetErrorCallback(value);
+            }
+        }
+
+        public static LockingPolicy LockingPolicy
+        {
+            get
+            {
+                return CgNativeMethods.cgGetLockingPolicy();
+            }
+
+            set
+            {
+                CgNativeMethods.cgSetLockingPolicy(value);
+            }
+        }
+
+        public static CasePolicy SemanticCasePolicy
+        {
+            get
+            {
+                return CgNativeMethods.cgGetSemanticCasePolicy();
+            }
+
+            set
+            {
+                CgNativeMethods.cgSetSemanticCasePolicy(value);
+            }
+        }
+
+        public static int SupportedProfilesCount
+        {
+            get
+            {
+                return CgNativeMethods.cgGetNumSupportedProfiles();
+            }
+        }
+
+        #endregion Public Static Properties
+
+        #endregion Properties
+
         #region Methods
 
         #region Public Static Methods
             return CgNativeMethods.cgGetEnum(enumString);
         }
 
-        public static string GetEnumString(int en)
+        public static string GetEnumString(int @enum)
         {
-            return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetEnumString(en));
+            return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetEnumString(@enum));
         }
 
         public static ErrorType GetError()
             return CgNativeMethods.cgGetError();
         }
 
-        public static CgErrorCallbackFuncDelegate GetErrorCallback()
-        {
-            return CgNativeMethods.cgGetErrorCallback();
-        }
-
         public static CgErrorHandlerFuncDelegate GetErrorHandler(IntPtr data)
         {
             return CgNativeMethods.cgGetErrorHandler(data);
         }
 
-        public static IntPtr GetErrorString(ErrorType error)
+        public static string GetErrorString(ErrorType error)
         {
-            return CgNativeMethods.cgGetErrorString(error);
+            return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetErrorString(error));
         }
 
         public static ErrorType GetFirstError()
             return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetLastErrorString(out error));
         }
 
-        public static LockingPolicy GetLockingPolicy()
-        {
-            return CgNativeMethods.cgGetLockingPolicy();
-        }
-
         public static ParameterType GetMatrixSize(ParameterType type, out int nrows, out int ncols)
         {
             return CgNativeMethods.cgGetMatrixSize(type, out nrows, out ncols);
             return CgNativeMethods.cgGetNumParentTypes(type);
         }
 
-        public static int GetNumSupportedProfiles()
-        {
-            return CgNativeMethods.cgGetNumSupportedProfiles();
-        }
-
         public static ParameterClass GetParameterClassEnum(string pString)
         {
             return CgNativeMethods.cgGetParameterClassEnum(pString);
             return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetResourceString(resource));
         }
 
-        public static CasePolicy GetSemanticCasePolicy()
-        {
-            return CgNativeMethods.cgGetSemanticCasePolicy();
-        }
-
         public static string GetString(CgAll sname)
         {
             return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetString(sname));
             return CgNativeMethods.cgIsProfileSupported(profile);
         }
 
-        public static void SetErrorCallback(CgErrorCallbackFuncDelegate func)
-        {
-            CgNativeMethods.cgSetErrorCallback(func);
-        }
-
         public static void SetErrorHandler(CgErrorHandlerFuncDelegate func, IntPtr data)
         {
             CgNativeMethods.cgSetErrorHandler(func, data);
         }
 
-        public static LockingPolicy SetLockingPolicy(LockingPolicy lockingPolicy)
-        {
-            return CgNativeMethods.cgSetLockingPolicy(lockingPolicy);
-        }
-
-        public static CasePolicy SetSemanticCasePolicy(CasePolicy casePolicy)
-        {
-            return CgNativeMethods.cgSetSemanticCasePolicy(casePolicy);
-        }
-
         #endregion Public Static Methods
 
         #region Internal Static Methods
 
-        internal static T[] GetMatrixParameter<T>(IntPtr param, Order order)
-            where T : struct
-        {
-            var retValue = new T[16];
-            GCHandle handle = GCHandle.Alloc(retValue, GCHandleType.Pinned);
-
-            try
-            {
-                if (typeof(T) == typeof(double))
-                {
-                    switch (order)
-                    {
-                        case Order.ColumnMajor:
-                            CgNativeMethods.cgGetMatrixParameterdc(param, handle.AddrOfPinnedObject());
-                            break;
-                        case Order.RowMajor:
-                            CgNativeMethods.cgGetMatrixParameterdr(param, handle.AddrOfPinnedObject());
-                            break;
-                        default:
-                            throw new InvalidEnumArgumentException("order");
-                    }
-                }
-                else if (typeof(T) == typeof(float))
-                {
-                    switch (order)
-                    {
-                        case Order.ColumnMajor:
-                            CgNativeMethods.cgGetMatrixParameterfc(param, handle.AddrOfPinnedObject());
-                            break;
-                        case Order.RowMajor:
-                            CgNativeMethods.cgGetMatrixParameterfr(param, handle.AddrOfPinnedObject());
-                            break;
-                        default:
-                            throw new InvalidEnumArgumentException("order");
-                    }
-                }
-                else if (typeof(T) == typeof(int))
-                {
-                    switch (order)
-                    {
-                        case Order.ColumnMajor:
-                            CgNativeMethods.cgGetMatrixParameteric(param, handle.AddrOfPinnedObject());
-                            break;
-                        case Order.RowMajor:
-                            CgNativeMethods.cgGetMatrixParameterir(param, handle.AddrOfPinnedObject());
-                            break;
-                        default:
-                            throw new InvalidEnumArgumentException("order");
-                    }
-                }
-                else
-                {
-                    throw new ArgumentException();
-                }
-
-                return retValue;
-            }
-            finally
-            {
-                handle.Free();
-            }
-        }
-
-        internal static int GetParameterDefaultValue(IntPtr param, ref double[] values, Order order)
-        {
-            switch (order)
-            {
-                case Order.ColumnMajor:
-                    return CgNativeMethods.cgGetParameterDefaultValuedc(param, values.Length, values);
-                case Order.RowMajor:
-                    return CgNativeMethods.cgGetParameterDefaultValuedr(param, values.Length, values);
-                default:
-                    throw new ArgumentOutOfRangeException("order");
-            }
-        }
-
-        internal static int GetParameterDefaultValue(IntPtr param, ref int[] values, Order order)
-        {
-            switch (order)
-            {
-                case Order.ColumnMajor:
-                    return CgNativeMethods.cgGetParameterDefaultValueic(param, values.Length, values);
-                case Order.RowMajor:
-                    return CgNativeMethods.cgGetParameterDefaultValueir(param, values.Length, values);
-                default:
-                    throw new ArgumentOutOfRangeException("order");
-            }
-        }
-
-        internal static int GetParameterDefaultValue(IntPtr param, ref float[] values, Order order)
-        {
-            switch (order)
-            {
-                case Order.ColumnMajor:
-                    return CgNativeMethods.cgGetParameterDefaultValuefc(param, values.Length, values);
-                case Order.RowMajor:
-                    return CgNativeMethods.cgGetParameterDefaultValuefr(param, values.Length, values);
-                default:
-                    throw new ArgumentOutOfRangeException("order");
-            }
-        }
-
-        internal static T GetParameterValue<T>(IntPtr param)
-            where T : struct
-        {
-            var f = new T[1];
-            GetParameterValue(param, ref f);
-            return f[0];
-        }
-
-        internal static void GetParameterValue<T>(IntPtr param, ref T[] values)
-            where T : struct
-        {
-            GetParameterValue(param, ref values, Order.RowMajor);
-        }
-
-        internal static void GetParameterValue<T>(IntPtr param, ref T[] values, Order order)
-            where T : struct
-        {
-            GCHandle handle = GCHandle.Alloc(values, GCHandleType.Pinned);
-            try
-            {
-                if (typeof(T) == typeof(int))
-                {
-                    switch (order)
-                    {
-                        case Order.ColumnMajor:
-                            CgNativeMethods.cgGetParameterValueic(param, values.Length, handle.AddrOfPinnedObject());
-                            break;
-                        case Order.RowMajor:
-                            CgNativeMethods.cgGetParameterValueir(param, values.Length, handle.AddrOfPinnedObject());
-                            break;
-                        default:
-                            throw new InvalidEnumArgumentException("order");
-                    }
-                }
-                else if (typeof(T) == typeof(double))
-                {
-                    switch (order)
-                    {
-                        case Order.ColumnMajor:
-                            CgNativeMethods.cgGetParameterValuedc(param, values.Length, handle.AddrOfPinnedObject());
-                            break;
-                        case Order.RowMajor:
-                            CgNativeMethods.cgGetParameterValuedr(param, values.Length, handle.AddrOfPinnedObject());
-                            break;
-                        default:
-                            throw new InvalidEnumArgumentException("order");
-                    }
-                }
-                else if (typeof(T) == typeof(float))
-                {
-                    switch (order)
-                    {
-                        case Order.ColumnMajor:
-                            CgNativeMethods.cgGetParameterValuefc(param, values.Length, handle.AddrOfPinnedObject());
-                            break;
-                        case Order.RowMajor:
-                            CgNativeMethods.cgGetParameterValuefr(param, values.Length, handle.AddrOfPinnedObject());
-                            break;
-                        default:
-                            throw new InvalidEnumArgumentException("order");
-                    }
-                }
-            }
-            finally
-            {
-                handle.Free();
-            }
-        }
-
         internal static bool[] IntPtrToBoolArray(IntPtr values, int count)
         {
             if (count > 0)
             return lines.Count == 0 ? null : lines.ToArray();
         }
 
-        internal static void SetMatrixParameter(IntPtr param, float[] matrix, Order order)
-        {
-            switch (order)
-            {
-                case Order.ColumnMajor:
-                    CgNativeMethods.cgSetMatrixParameterfc(param, matrix);
-                    break;
-                case Order.RowMajor:
-                    CgNativeMethods.cgSetMatrixParameterfr(param, matrix);
-                    break;
-                default:
-                    throw new InvalidEnumArgumentException("order");
-            }
-        }
-
-        internal static void SetMatrixParameter(IntPtr param, double[] matrix, Order order)
-        {
-            switch (order)
-            {
-                case Order.ColumnMajor:
-                    CgNativeMethods.cgSetMatrixParameterdc(param, matrix);
-                    break;
-                case Order.RowMajor:
-                    CgNativeMethods.cgSetMatrixParameterdr(param, matrix);
-                    break;
-                default:
-                    throw new InvalidEnumArgumentException("order");
-            }
-        }
-
-        internal static void SetMatrixParameter(IntPtr param, int[] matrix, Order order)
-        {
-            switch (order)
-            {
-                case Order.ColumnMajor:
-                    CgNativeMethods.cgSetMatrixParameteric(param, matrix);
-                    break;
-                case Order.RowMajor:
-                    CgNativeMethods.cgSetMatrixParameterir(param, matrix);
-                    break;
-                default:
-                    throw new InvalidEnumArgumentException("order");
-            }
-        }
-
-        internal static void SetParameterValue(IntPtr param, double[] vals, Order order)
-        {
-            switch (order)
-            {
-                case Order.ColumnMajor:
-                    CgNativeMethods.cgSetParameterValuedc(param, vals.Length, vals);
-                    break;
-                case Order.RowMajor:
-                    CgNativeMethods.cgSetParameterValuedr(param, vals.Length, vals);
-                    break;
-                default:
-                    throw new InvalidEnumArgumentException("order");
-            }
-        }
-
-        internal static void SetParameterValue(IntPtr param, float[] vals, Order order)
-        {
-            switch (order)
-            {
-                case Order.ColumnMajor:
-                    CgNativeMethods.cgSetParameterValuefc(param, vals.Length, vals);
-                    break;
-                case Order.RowMajor:
-                    CgNativeMethods.cgSetParameterValuefr(param, vals.Length, vals);
-                    break;
-                default:
-                    throw new InvalidEnumArgumentException("order");
-            }
-        }
-
-        internal static void SetParameterValue(IntPtr param, int[] vals, Order order)
-        {
-            switch (order)
-            {
-                case Order.ColumnMajor:
-                    CgNativeMethods.cgSetParameterValueic(param, vals.Length, vals);
-                    break;
-                case Order.RowMajor:
-                    CgNativeMethods.cgSetParameterValueir(param, vals.Length, vals);
-                    break;
-                default:
-                    throw new InvalidEnumArgumentException("order");
-            }
-        }
-
         #endregion Internal Static Methods
 
         #endregion Methods

File CgNet/GL/CgGLParameter.cs

             CgGLNativeMethods.cgGLEnableClientState(param.Handle);
         }
 
-        public static void GetMatrixParameter(this Parameter param, out Matrix4 value)
-        {
-            value = CgGL.GetMatrixParameter<Matrix4>(param.Handle, Order.RowMajor);
-        }
-
-        public static void GetMatrixParameter(this Parameter param, out Matrix4d value)
-        {
-            value = CgGL.GetMatrixParameter<Matrix4d>(param.Handle, Order.RowMajor);
-        }
-
-        public static T GetMatrixParameter<T>(this Parameter param)
-            where T : struct
-        {
-            return CgGL.GetMatrixParameter<T>(param.Handle, Order.RowMajor);
-        }
-
-        public static T GetMatrixParameter<T>(this Parameter param, Order order)
-            where T : struct
-        {
-            return CgGL.GetMatrixParameter<T>(param.Handle, order);
-        }
-
-        public static void GetMatrixParameterArray(this Parameter param, int offset, int nelements, out Matrix4[] values)
-        {
-            values = CgGL.GetMatrixParameterArray<Matrix4>(param.Handle, offset, nelements, Order.RowMajor);
-        }
-
-        public static void GetMatrixParameterArray(this Parameter param, int offset, int nelements, out Matrix4d[] values)
-        {
-            values = CgGL.GetMatrixParameterArray<Matrix4d>(param.Handle, offset, nelements, Order.RowMajor);
-        }
-
-        public static T[] GetMatrixParameterArray<T>(this Parameter param, int offset, int nelements)
-            where T : struct
-        {
-            return CgGL.GetMatrixParameterArray<T>(param.Handle, offset, nelements, Order.RowMajor);
-        }
-
-        public static T[] GetMatrixParameterArray<T>(this Parameter param, int offset, int nelements, Order order)
-            where T : struct
-        {
-            return CgGL.GetMatrixParameterArray<T>(param.Handle, offset, nelements, order);
-        }
-
-        public static T GetParameter<T>(this Parameter param)
+        public static T Get<T>(this Parameter param)
             where T : struct
         {
             IntPtr param1 = param.Handle;
             }
         }
 
-        public static void GetParameter(this Parameter param, ref float[] values)
+        public static void Get(this Parameter param, ref float[] values)
         {
             IntPtr param1 = param.Handle;
             GCHandle handle = GCHandle.Alloc(values, GCHandleType.Pinned);
             }
         }
 
-        public static void GetParameter(this Parameter param, ref double[] values)
+        public static void Get(this Parameter param, ref double[] values)
         {
             IntPtr param1 = param.Handle;
             GCHandle handle = GCHandle.Alloc(values);
             }
         }
 
-        public static void GetParameterArray(this Parameter param, int offset, int nelements, ref float[] values)
+        public static void GetArray(this Parameter param, int offset, int nelements, ref float[] values)
         {
             IntPtr param1 = param.Handle;
             GCHandle g = GCHandle.Alloc(values, GCHandleType.Pinned);
             }
         }
 
-        public static void GetParameterArray(this Parameter param, int offset, int nelements, ref double[] values)
+        public static void GetArray(this Parameter param, int offset, int nelements, ref double[] values)
         {
             IntPtr param1 = param.Handle;
             GCHandle g = GCHandle.Alloc(values, GCHandleType.Pinned);
             }
         }
 
+        public static void GetMatrix(this Parameter param, out Matrix4 value)
+        {
+            value = CgGL.GetMatrixParameter<Matrix4>(param.Handle, Order.RowMajor);
+        }
+
+        public static void GetMatrix(this Parameter param, out Matrix4d value)
+        {
+            value = CgGL.GetMatrixParameter<Matrix4d>(param.Handle, Order.RowMajor);
+        }
+
+        public static T GetMatrix<T>(this Parameter param)
+            where T : struct
+        {
+            return CgGL.GetMatrixParameter<T>(param.Handle, Order.RowMajor);
+        }
+
+        public static T GetMatrix<T>(this Parameter param, Order order)
+            where T : struct
+        {
+            return CgGL.GetMatrixParameter<T>(param.Handle, order);
+        }
+
+        public static void GetMatrixArray(this Parameter param, int offset, int nelements, out Matrix4[] values)
+        {
+            values = CgGL.GetMatrixParameterArray<Matrix4>(param.Handle, offset, nelements, Order.RowMajor);
+        }
+
+        public static void GetMatrixArray(this Parameter param, int offset, int nelements, out Matrix4d[] values)
+        {
+            values = CgGL.GetMatrixParameterArray<Matrix4d>(param.Handle, offset, nelements, Order.RowMajor);
+        }
+
+        public static T[] GetMatrixArray<T>(this Parameter param, int offset, int nelements)
+            where T : struct
+        {
+            return CgGL.GetMatrixParameterArray<T>(param.Handle, offset, nelements, Order.RowMajor);
+        }
+
+        public static T[] GetMatrixArray<T>(this Parameter param, int offset, int nelements, Order order)
+            where T : struct
+        {
+            return CgGL.GetMatrixParameterArray<T>(param.Handle, offset, nelements, order);
+        }
+
         public static int GetTextureEnum(this Parameter param)
         {
             return CgGLNativeMethods.cgGLGetTextureEnum(param.Handle);
             }
         }
 
-        public static void SetMatrixParameter(this Parameter param, Matrix4 matrix)
+        public static void SetMatrix(this Parameter param, Matrix4 matrix)
         {
             IntPtr param1 = param.Handle;
             Order order = Order.RowMajor;
             }
         }
 
-        public static void SetMatrixParameter(this Parameter param, Matrix4 matrix, Order order)
+        public static void SetMatrix(this Parameter param, Matrix4 matrix, Order order)
         {
             IntPtr param1 = param.Handle;
             switch (order)
             }
         }
 
-        public static void SetMatrixParameter(this Parameter param, Matrix4d matrix)
+        public static void SetMatrix(this Parameter param, Matrix4d matrix)
         {
             CgGL.SetMatrixParameter(param.Handle, matrix, Order.RowMajor);
         }
 
-        public static void SetMatrixParameter(this Parameter param, Matrix4d matrix, Order order)
+        public static void SetMatrix(this Parameter param, Matrix4d matrix, Order order)
         {
             CgGL.SetMatrixParameter(param.Handle, matrix, order);
         }
 
-        public static void SetMatrixParameterArray(this Parameter param, int offset, int nelements, Matrix4d[] matrices)
+        public static void SetMatrixArray(this Parameter param, int offset, int nelements, Matrix4d[] matrices)
         {
             CgGL.SetMatrixParameterArray(param.Handle, offset, nelements, matrices, Order.RowMajor);
         }
 
-        public static void SetMatrixParameterArray(this Parameter param, int offset, int nelements, Matrix4[] matrices)
+        public static void SetMatrixArray(this Parameter param, int offset, int nelements, Matrix4[] matrices)
         {
             CgGL.SetMatrixParameterArray(param.Handle, offset, nelements, matrices, Order.RowMajor);
         }
 
-        public static void SetMatrixParameterArray(this Parameter param, int offset, int nelements, Matrix4d[] matrices, Order order)
+        public static void SetMatrixArray(this Parameter param, int offset, int nelements, Matrix4d[] matrices, Order order)
         {
             CgGL.SetMatrixParameterArray(param.Handle, offset, nelements, matrices, order);
         }
 
-        public static void SetMatrixParameterArray(this Parameter param, int offset, int nelements, Matrix4[] matrices, Order order)
+        public static void SetMatrixArray(this Parameter param, int offset, int nelements, Matrix4[] matrices, Order order)
         {
             CgGL.SetMatrixParameterArray(param.Handle, offset, nelements, matrices, order);
         }

File CgNet/Obj.cs

 
         #endregion Constructors
 
+        #region Properties
+
+        #region Public Properties
+
+        public int UserTypesCount
+        {
+            get
+            {
+                return CgNativeMethods.cgGetNumUserTypes(this.Handle);
+            }
+        }
+
+        #endregion Public Properties
+
+        #endregion Properties
+
         #region Methods
 
         #region Public Static Methods
 
         #endregion Public Static Methods
 
+        #region Public Methods
+
+        public ParameterType GetNamedUserType(string name)
+        {
+            return CgNativeMethods.cgGetNamedUserType(this.Handle, name);
+        }
+
+        public ParameterType GetUserType(int index)
+        {
+            return CgNativeMethods.cgGetUserType(this.Handle, index);
+        }
+
+        #endregion Public Methods
+
         #region Protected Methods
 
         protected override void Dispose(bool disposing)

File CgNet/Parameter.cs

 {
     using System;
     using System.Collections.Generic;
+    using System.ComponentModel;
     using System.Runtime.InteropServices;
 
     public sealed class Parameter : WrapperObject
 
         public int GetDefaultValue(ref double[] values)
         {
-            return Cg.GetParameterDefaultValue(this.Handle, ref values, Order.RowMajor);
+            return this.GetDefaultValue(ref values, Order.RowMajor);
         }
 
         public int GetDefaultValue(ref double[] values, Order order)
         {
-            return Cg.GetParameterDefaultValue(this.Handle, ref values, order);
+            IntPtr param = this.Handle;
+            switch (order)
+            {
+                case Order.ColumnMajor:
+                    return CgNativeMethods.cgGetParameterDefaultValuedc(param, values.Length, values);
+                case Order.RowMajor:
+                    return CgNativeMethods.cgGetParameterDefaultValuedr(param, values.Length, values);
+                default:
+                    throw new ArgumentOutOfRangeException("order");
+            }
         }
 
         public int GetDefaultValue(ref int[] values)
         {
-            return Cg.GetParameterDefaultValue(this.Handle, ref values, Order.RowMajor);
+            return this.GetDefaultValue(ref values, Order.RowMajor);
         }
 
         public int GetDefaultValue(ref int[] values, Order order)
         {
-            return Cg.GetParameterDefaultValue(this.Handle, ref values, order);
+            IntPtr param = this.Handle;
+            switch (order)
+            {
+                case Order.ColumnMajor:
+                    return CgNativeMethods.cgGetParameterDefaultValueic(param, values.Length, values);
+                case Order.RowMajor:
+                    return CgNativeMethods.cgGetParameterDefaultValueir(param, values.Length, values);
+                default:
+                    throw new ArgumentOutOfRangeException("order");
+            }
         }
 
         public int GetDefaultValue(ref float[] values)
         {
-            return Cg.GetParameterDefaultValue(this.Handle, ref values, Order.RowMajor);
+            return this.GetDefaultValue(ref values, Order.RowMajor);
         }
 
         public int GetDefaultValue(ref float[] values, Order order)
         {
-            return Cg.GetParameterDefaultValue(this.Handle, ref values, order);
+            IntPtr param = this.Handle;
+            switch (order)
+            {
+                case Order.ColumnMajor:
+                    return CgNativeMethods.cgGetParameterDefaultValuefc(param, values.Length, values);
+                case Order.RowMajor:
+                    return CgNativeMethods.cgGetParameterDefaultValuefr(param, values.Length, values);
+                default:
+                    throw new ArgumentOutOfRangeException("order");
+            }
         }
 
         public Buffer GetEffectParameterBuffer()
                                                };
         }
 
-        public void GetMatrixParameter(out int[] values)
+        public void GetMatrix(out int[] values)
         {
-            values = Cg.GetMatrixParameter<int>(this.Handle, Order.RowMajor);
+            values = this.GetMatrix<int>(Order.RowMajor);
         }
 
-        public void GetMatrixParameter(out float[] values)
+        public void GetMatrix(out float[] values)
         {
-            values = Cg.GetMatrixParameter<float>(this.Handle, Order.RowMajor);
+            values = this.GetMatrix<float>(Order.RowMajor);
         }
 
-        public void GetMatrixParameter(out double[] values)
+        public void GetMatrix(out double[] values)
         {
-            values = Cg.GetMatrixParameter<double>(this.Handle, Order.RowMajor);
+            values = this.GetMatrix<double>(Order.RowMajor);
         }
 
-        public T[] GetMatrixParameter<T>()
+        public T[] GetMatrix<T>()
             where T : struct
         {
-            return Cg.GetMatrixParameter<T>(this.Handle, Order.RowMajor);
+            return this.GetMatrix<T>(Order.RowMajor);
         }
 
-        public T[] GetMatrixParameter<T>(Order order)
+        public T[] GetMatrix<T>(Order order)
             where T : struct
         {
-            return Cg.GetMatrixParameter<T>(this.Handle, order);
+            IntPtr param = this.Handle;
+            var retValue = new T[16];
+            GCHandle handle = GCHandle.Alloc(retValue, GCHandleType.Pinned);
+
+            try
+            {
+                if (typeof(T) == typeof(double))
+                {
+                    switch (order)
+                    {
+                        case Order.ColumnMajor:
+                            CgNativeMethods.cgGetMatrixParameterdc(param, handle.AddrOfPinnedObject());
+                            break;
+                        case Order.RowMajor:
+                            CgNativeMethods.cgGetMatrixParameterdr(param, handle.AddrOfPinnedObject());
+                            break;
+                        default:
+                            throw new InvalidEnumArgumentException("order");
+                    }
+                }
+                else if (typeof(T) == typeof(float))
+                {
+                    switch (order)
+                    {
+                        case Order.ColumnMajor:
+                            CgNativeMethods.cgGetMatrixParameterfc(param, handle.AddrOfPinnedObject());
+                            break;
+                        case Order.RowMajor:
+                            CgNativeMethods.cgGetMatrixParameterfr(param, handle.AddrOfPinnedObject());
+                            break;
+                        default:
+                            throw new InvalidEnumArgumentException("order");
+                    }
+                }
+                else if (typeof(T) == typeof(int))
+                {
+                    switch (order)
+                    {
+                        case Order.ColumnMajor:
+                            CgNativeMethods.cgGetMatrixParameteric(param, handle.AddrOfPinnedObject());
+                            break;
+                        case Order.RowMajor:
+                            CgNativeMethods.cgGetMatrixParameterir(param, handle.AddrOfPinnedObject());
+                            break;
+                        default:
+                            throw new InvalidEnumArgumentException("order");
+                    }
+                }
+                else
+                {
+                    throw new ArgumentException();
+                }
+
+                return retValue;
+            }
+            finally
+            {
+                handle.Free();
+            }
         }
 
-        public Order GetMatrixParameterOrder()
+        public Order GetMatrixOrder()
         {
             return CgNativeMethods.cgGetMatrixParameterOrder(this.Handle);
         }
 
         public void GetValue(ref int[] values)
         {
-            Cg.GetParameterValue(this.Handle, ref values, Order.RowMajor);
+            this.GetValue(ref values, Order.RowMajor);
+        }
+
+        public void GetValue(ref int[] values, Order order)
+        {
+            GCHandle handle = GCHandle.Alloc(values, GCHandleType.Pinned);
+            try
+            {
+                switch (order)
+                {
+                    case Order.ColumnMajor:
+                        CgNativeMethods.cgGetParameterValueic(this.Handle, values.Length, handle.AddrOfPinnedObject());
+                        break;
+                    case Order.RowMajor:
+                        CgNativeMethods.cgGetParameterValueir(this.Handle, values.Length, handle.AddrOfPinnedObject());
+                        break;
+                    default:
+                        throw new InvalidEnumArgumentException("order");
+                }
+            }
+            finally
+            {
+                handle.Free();
+            }
         }
 
         public void GetValue(ref double[] values)
         {
-            Cg.GetParameterValue(this.Handle, ref values, Order.RowMajor);
+            this.GetValue(ref values, Order.RowMajor);
+        }
+
+        public void GetValue(ref double[] values, Order order)
+        {
+            GCHandle handle = GCHandle.Alloc(values, GCHandleType.Pinned);
+            try
+            {
+                switch (order)
+                {
+                    case Order.ColumnMajor:
+                        CgNativeMethods.cgGetParameterValuedc(this.Handle, values.Length, handle.AddrOfPinnedObject());
+                        break;
+                    case Order.RowMajor:
+                        CgNativeMethods.cgGetParameterValuedr(this.Handle, values.Length, handle.AddrOfPinnedObject());
+                        break;
+                    default:
+                        throw new InvalidEnumArgumentException("order");
+                }
+            }
+            finally
+            {
+                handle.Free();
+            }
         }
 
         public void GetValue(ref float[] values)
         {
-            Cg.GetParameterValue(this.Handle, ref values, Order.RowMajor);
+            this.GetValue(ref values, Order.RowMajor);
+        }
+
+        public void GetValue(ref float[] values, Order order)
+        {
+            GCHandle handle = GCHandle.Alloc(values, GCHandleType.Pinned);
+            try
+            {
+                switch (order)
+                {
+                    case Order.ColumnMajor:
+                        CgNativeMethods.cgGetParameterValuefc(this.Handle, values.Length, handle.AddrOfPinnedObject());
+                        break;
+                    case Order.RowMajor:
+                        CgNativeMethods.cgGetParameterValuefr(this.Handle, values.Length, handle.AddrOfPinnedObject());
+                        break;
+                    default:
+                        throw new InvalidEnumArgumentException("order");
+                }
+            }
+            finally
+            {
+                handle.Free();
+            }
         }
 
         public T GetValue<T>()
             where T : struct
         {
-            return Cg.GetParameterValue<T>(this.Handle);
-        }
+            var f = new T[1];
+            GCHandle handle = GCHandle.Alloc(f, GCHandleType.Pinned);
+            try
+            {
+                if (typeof(T) == typeof(int))
+                {
+                    CgNativeMethods.cgGetParameterValueir(this.Handle, f.Length, handle.AddrOfPinnedObject());
+                }
+                else if (typeof(T) == typeof(double))
+                {
+                    CgNativeMethods.cgGetParameterValuedr(this.Handle, f.Length, handle.AddrOfPinnedObject());
+                }
+                else if (typeof(T) == typeof(float))
+                {
+                    CgNativeMethods.cgGetParameterValuefr(this.Handle, f.Length, handle.AddrOfPinnedObject());
+                }
+            }
+            finally
+            {
+                handle.Free();
+            }
 
-        public void GetValue<T>(ref T[] values)
-            where T : struct
-        {
-            Cg.GetParameterValue(this.Handle, ref values, Order.RowMajor);
-        }
-
-        public void GetValue<T>(ref T[] values, Order order)
-            where T : struct
-        {
-            Cg.GetParameterValue(this.Handle, ref values, order);
+            return f[0];
         }
 
         public bool IsParameterUsed(WrapperObject container)
             CgNativeMethods.cgSetParameter1f(this.Handle, x);
         }
 
+        public void Set(float x, float y)
+        {
+            CgNativeMethods.cgSetParameter2f(this.Handle, x, y);
+        }
+
         public void Set(float x, float y, float z)
         {
             CgNativeMethods.cgSetParameter3f(this.Handle, x, y, z);
         }
 
+        public void Set(float x, float y, float z, float w)
+        {
+            CgNativeMethods.cgSetParameter4f(this.Handle, x, y, z, w);
+        }
+
+        public void Set(float[] v)
+        {
+            IntPtr param = this.Handle;
+            switch (v.Length)
+            {
+                case 1:
+                    CgNativeMethods.cgSetParameter1fv(param, v);
+                    break;
+                case 2:
+                    CgNativeMethods.cgSetParameter2fv(param, v);
+                    break;
+                case 3:
+                    CgNativeMethods.cgSetParameter3fv(param, v);
+                    break;
+                case 4:
+                    CgNativeMethods.cgSetParameter4fv(param, v);
+                    break;
+                default:
+                    throw new ArgumentException();
+            }
+        }
+
+        public void Set(int x)
+        {
+            CgNativeMethods.cgSetParameter1i(this.Handle, x);
+        }
+
+        public void Set(int x, int y)
+        {
+            CgNativeMethods.cgSetParameter2i(this.Handle, x, y);
+        }
+
+        public void Set(int x, int y, int z)
+        {
+            CgNativeMethods.cgSetParameter3i(this.Handle, x, y, z);
+        }
+
+        public void Set(int x, int y, int z, int w)
+        {
+            CgNativeMethods.cgSetParameter4i(this.Handle, x, y, z, w);
+        }
+
         public void Set(int[] v)
         {
             IntPtr param = this.Handle;
             }
         }
 
+        public void Set(double x)
+        {
+            CgNativeMethods.cgSetParameter1d(this.Handle, x);
+        }
+
+        public void Set(double x, double y)
+        {
+            CgNativeMethods.cgSetParameter2d(this.Handle, x, y);
+        }
+
+        public void Set(double x, double y, double z)
+        {
+            CgNativeMethods.cgSetParameter3d(this.Handle, x, y, z);
+        }
+
+        public void Set(double x, double y, double z, double w)
+        {
+            CgNativeMethods.cgSetParameter4d(this.Handle, x, y, z, w);
+        }
+
         public void Set(double[] v)
         {
             IntPtr param = this.Handle;
             }
         }
 
-        public void Set(float[] v)
-        {
-            IntPtr param = this.Handle;
-            switch (v.Length)
-            {
-                case 1:
-                    CgNativeMethods.cgSetParameter1fv(param, v);
-                    break;
-                case 2:
-                    CgNativeMethods.cgSetParameter2fv(param, v);
-                    break;
-                case 3:
-                    CgNativeMethods.cgSetParameter3fv(param, v);
-                    break;
-                case 4:
-                    CgNativeMethods.cgSetParameter4fv(param, v);
-                    break;
-                default:
-                    throw new ArgumentException();
-            }
-        }
-
-        public void Set(float x, float y)
-        {
-            CgNativeMethods.cgSetParameter2f(this.Handle, x, y);
-        }
-
-        public void Set(float x, float y, float z, float w)
-        {
-            CgNativeMethods.cgSetParameter4f(this.Handle, x, y, z, w);
-        }
-
-        public void Set(double x)
-        {
-            CgNativeMethods.cgSetParameter1d(this.Handle, x);
-        }
-
-        public void Set(int x)
-        {
-            CgNativeMethods.cgSetParameter1i(this.Handle, x);
-        }
-
-        public void Set(double x, double y)
-        {
-            CgNativeMethods.cgSetParameter2d(this.Handle, x, y);
-        }
-
-        public void Set(int x, int y)
-        {
-            CgNativeMethods.cgSetParameter2i(this.Handle, x, y);
-        }
-
-        public void Set(double x, double y, double z)
-        {
-            CgNativeMethods.cgSetParameter3d(this.Handle, x, y, z);
-        }
-
-        public void Set(int x, int y, int z)
-        {
-            CgNativeMethods.cgSetParameter3i(this.Handle, x, y, z);
-        }
-
-        public void Set(double x, double y, double z, double w)
-        {
-            CgNativeMethods.cgSetParameter4d(this.Handle, x, y, z, w);
-        }
-
-        public void Set(int x, int y, int z, int w)
-        {
-            CgNativeMethods.cgSetParameter4i(this.Handle, x, y, z, w);
-        }
-
         public void Set1(int[] v)
         {
             CgNativeMethods.cgSetParameter1iv(this.Handle, v);
 
         public void SetMatrix(float[] matrix)
         {
-            Cg.SetMatrixParameter(this.Handle, matrix, Order.RowMajor);
+            this.SetMatrix(matrix, Order.RowMajor);
         }
 
         public void SetMatrix(float[] matrix, Order order)
         {
-            Cg.SetMatrixParameter(this.Handle, matrix, order);
+            IntPtr param = this.Handle;
+            switch (order)
+            {
+                case Order.ColumnMajor:
+                    CgNativeMethods.cgSetMatrixParameterfc(param, matrix);
+                    break;
+                case Order.RowMajor:
+                    CgNativeMethods.cgSetMatrixParameterfr(param, matrix);
+                    break;
+                default:
+                    throw new InvalidEnumArgumentException("order");
+            }
         }
 
         public void SetMatrix(double[] matrix)
         {
-            Cg.SetMatrixParameter(this.Handle, matrix, Order.RowMajor);
+            this.SetMatrix(matrix, Order.RowMajor);
         }
 
         public void SetMatrix(double[] matrix, Order order)
         {
-            Cg.SetMatrixParameter(this.Handle, matrix, order);
+            IntPtr param = this.Handle;
+            switch (order)
+            {
+                case Order.ColumnMajor:
+                    CgNativeMethods.cgSetMatrixParameterdc(param, matrix);
+                    break;
+                case Order.RowMajor:
+                    CgNativeMethods.cgSetMatrixParameterdr(param, matrix);
+                    break;
+                default:
+                    throw new InvalidEnumArgumentException("order");
+            }
         }
 
         public void SetMatrix(int[] matrix)
         {
-            Cg.SetMatrixParameter(this.Handle, matrix, Order.RowMajor);
+            this.SetMatrix(matrix, Order.RowMajor);
         }
 
         public void SetMatrix(int[] matrix, Order order)
         {
-            Cg.SetMatrixParameter(this.Handle, matrix, order);
+            IntPtr param = this.Handle;
+            switch (order)
+            {
+                case Order.ColumnMajor:
+                    CgNativeMethods.cgSetMatrixParameteric(param, matrix);
+                    break;
+                case Order.RowMajor:
+                    CgNativeMethods.cgSetMatrixParameterir(param, matrix);
+                    break;
+                default:
+                    throw new InvalidEnumArgumentException("order");
+            }
         }
 
         public void SetMultiDimArraySize(int[] sizes)
 
         public void SetValue(double[] vals)
         {
-            Cg.SetParameterValue(this.Handle, vals, Order.RowMajor);
+            this.SetValue(vals, Order.RowMajor);
         }
 
         public void SetValue(double[] vals, Order order)
         {
-            Cg.SetParameterValue(this.Handle, vals, order);
+            IntPtr param = this.Handle;
+            switch (order)
+            {
+                case Order.ColumnMajor:
+                    CgNativeMethods.cgSetParameterValuedc(param, vals.Length, vals);
+                    break;
+                case Order.RowMajor:
+                    CgNativeMethods.cgSetParameterValuedr(param, vals.Length, vals);
+                    break;
+                default:
+                    throw new InvalidEnumArgumentException("order");
+            }
         }
 
         public void SetValue(float[] vals)
         {
-            Cg.SetParameterValue(this.Handle, vals, Order.RowMajor);
+            this.SetValue(vals, Order.RowMajor);
         }
 
         public void SetValue(float[] vals, Order order)
         {
-            Cg.SetParameterValue(this.Handle, vals, order);
+            IntPtr param = this.Handle;
+            switch (order)
+            {
+                case Order.ColumnMajor:
+                    CgNativeMethods.cgSetParameterValuefc(param, vals.Length, vals);
+                    break;
+                case Order.RowMajor:
+                    CgNativeMethods.cgSetParameterValuefr(param, vals.Length, vals);
+                    break;
+                default:
+                    throw new InvalidEnumArgumentException("order");
+            }
         }
 
         public void SetValue(int[] vals)
         {
-            Cg.SetParameterValue(this.Handle, vals, Order.RowMajor);
+            this.SetValue(vals, Order.RowMajor);
         }
 
         public void SetValue(int[] vals, Order order)
         {
-            Cg.SetParameterValue(this.Handle, vals, order);
+            IntPtr param = this.Handle;
+            switch (order)
+            {
+                case Order.ColumnMajor:
+                    CgNativeMethods.cgSetParameterValueic(param, vals.Length, vals);
+                    break;
+                case Order.RowMajor:
+                    CgNativeMethods.cgSetParameterValueir(param, vals.Length, vals);
+                    break;
+                default:
+                    throw new InvalidEnumArgumentException("order");
+            }
         }
 
         #endregion Public Methods

File ExampleBrowser/Examples/OpenTK/Example.cs

 
         public void Start()
         {
-            Cg.SetErrorCallback(CheckForCgError);
+            Cg.ErrorCallback = this.CheckForCgError;
             this.Run(30.0, 0.0);
         }
 

File ExampleBrowser/Examples/SlimDX/Example.cs

 
         public virtual void Start()
         {
-            Cg.SetErrorCallback(CheckForCgError);
+            Cg.ErrorCallback = this.CheckForCgError;
         }
 
         #endregion Public Methods