Commits

Tobias Bohnen committed 2efc2a3

* dropped C-like API

Comments (0)

Files changed (85)

CgNet/Annotation.cs

+ďťż/*
+ CgNet v1.0
+ Copyright (c) 2010 Tobias Bohnen
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ software and associated documentation files (the "Software"), to deal in the Software
+ without restriction, including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
+ to whom the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ */
+namespace CgNet
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Runtime.InteropServices;
+    using System.Text;
+
+    public sealed class Annotation : WrapperObject
+    {
+        #region Constructors
+
+        internal Annotation(IntPtr handle)
+            : base(handle)
+        {
+        }
+
+        #endregion Constructors
+
+        #region Properties
+
+        #region Public Properties
+
+        public int DependentParametersCount
+        {
+            get
+            {
+                return CgNativeMethods.cgGetNumDependentAnnotationParameters(this.Handle);
+            }
+        }
+
+        public bool IsAnnotation
+        {
+            get
+            {
+                return CgNativeMethods.cgIsAnnotation(this.Handle);
+            }
+        }
+
+        public string Name
+        {
+            get
+            {
+                return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetAnnotationName(this.Handle));
+            }
+        }
+
+        public Annotation NextAnnotation
+        {
+            get
+            {
+                var ptr = CgNativeMethods.cgGetNextAnnotation(this.Handle);
+                return ptr == IntPtr.Zero ? null : new Annotation(ptr)
+                                                   {
+                                                       OwnsHandle = false
+                                                   };
+            }
+        }
+
+        public ParameterType Type
+        {
+            get
+            {
+                return CgNativeMethods.cgGetAnnotationType(this.Handle);
+            }
+        }
+
+        #endregion Public Properties
+
+        #endregion Properties
+
+        #region Methods
+
+        #region Public Methods
+
+        public bool[] GetBoolValues()
+        {
+            int count;
+            var values = CgNativeMethods.cgGetBoolAnnotationValues(this.Handle, out count);
+            return Cg.IntPtrToBoolArray(values, count);
+        }
+
+        public Parameter GetDependentParameter(int index)
+        {
+            var ptr = CgNativeMethods.cgGetDependentAnnotationParameter(this.Handle, index);
+            return ptr == IntPtr.Zero ? null : new Parameter(ptr)
+                                               {
+                                                   OwnsHandle = false
+                                               };
+        }
+
+        public float[] GetFloatValues()
+        {
+            int nvalues;
+            return CgNativeMethods.cgGetFloatAnnotationValues(this.Handle, out nvalues);
+        }
+
+        public int[] GetIntValues()
+        {
+            int nvalues;
+            return CgNativeMethods.cgGetIntAnnotationValues(this.Handle, out nvalues);
+        }
+
+        public string[] GetStringAnnotationValues()
+        {
+            int nvalues;
+            var ptr = CgNativeMethods.cgGetStringAnnotationValues(this.Handle, out nvalues);
+            if (nvalues == 0)
+            {
+                return null;
+            }
+
+            unsafe
+            {
+                var byteArray = (byte**)ptr;
+                var lines = new List<string>();
+                var buffer = new List<byte>();
+
+                for (int i = 0; i < nvalues; i++)
+                {
+                    byte* b = *byteArray;
+                    for (;;)
+                    {
+                        if (*b == '\0')
+                        {
+                            char[] cc = Encoding.ASCII.GetChars(buffer.ToArray());
+                            lines.Add(new string(cc));
+                            buffer.Clear();
+                            break;
+                        }
+
+                        buffer.Add(*b);
+                        b++;
+                    }
+
+                    byteArray++;
+                }
+
+                return lines.ToArray();
+            }
+        }
+
+        public string GetStringValue()
+        {
+            return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetStringAnnotationValue(this.Handle));
+        }
+
+        public bool Set(int value)
+        {
+            return CgNativeMethods.cgSetIntAnnotation(this.Handle, value);
+        }
+
+        public bool Set(float value)
+        {
+            return CgNativeMethods.cgSetFloatAnnotation(this.Handle, value);
+        }
+
+        public bool Set(string value)
+        {
+            return CgNativeMethods.cgSetStringAnnotation(this.Handle, value);
+        }
+
+        public bool Set(bool value)
+        {
+            return CgNativeMethods.cgSetBoolAnnotation(this.Handle, value);
+        }
+
+        #endregion Public Methods
+
+        #endregion Methods
+    }
+}
+ďťż/*
+ CgNet v1.0
+ Copyright (c) 2010 Tobias Bohnen
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ software and associated documentation files (the "Software"), to deal in the Software
+ without restriction, including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
+ to whom the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ */
+namespace CgNet
+{
+    using System;
+
+    public sealed class Buffer : WrapperObject
+    {
+        #region Constructors
+
+        internal Buffer(IntPtr handle)
+            : base(handle)
+        {
+        }
+
+        #endregion Constructors
+
+        #region Properties
+
+        #region Public Properties
+
+        public int Size
+        {
+            get
+            {
+                return CgNativeMethods.cgGetBufferSize(this.Handle);
+            }
+        }
+
+        #endregion Public Properties
+
+        #endregion Properties
+
+        #region Methods
+
+        #region Public Static Methods
+
+        public static Buffer Create(Context context, int size, IntPtr data, BufferUsage bufferUsage)
+        {
+            return new Buffer(CgNativeMethods.cgCreateBuffer(context.Handle, size, data, bufferUsage));
+        }
+
+        #endregion Public Static Methods
+
+        #region Public Methods
+
+        public IntPtr Map(BufferAccess access)
+        {
+            return CgNativeMethods.cgMapBuffer(this.Handle, access);
+        }
+
+        public void SetData(int size, IntPtr data)
+        {
+            CgNativeMethods.cgSetBufferData(this.Handle, size, data);
+        }
+
+        public void SetSubData(int offset, int size, IntPtr data)
+        {
+            CgNativeMethods.cgSetBufferSubData(this.Handle, offset, size, data);
+        }
+
+        public void Unmap()
+        {
+            CgNativeMethods.cgUnmapBuffer(this.Handle);
+        }
+
+        #endregion Public Methods
+
+        #region Protected Methods
+
+        protected override void Dispose(bool disposing)
+        {
+            if (this.Handle != IntPtr.Zero)
+            {
+                CgNativeMethods.cgDestroyBuffer(this.Handle);
+            }
+        }
+
+        #endregion Protected Methods
+
+        #endregion Methods
+    }
+}
+ďťż/*
+ CgNet v1.0
+ Copyright (c) 2010 Tobias Bohnen
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ software and associated documentation files (the "Software"), to deal in the Software
+ without restriction, including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
+ to whom the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ */
+namespace CgNet
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel;
+    using System.Runtime.InteropServices;
+    using System.Text;
+
+    /// <summary>
+    /// 
+    /// </summary>
+    public static class Cg
+    {
+        #region Delegates
+
+        /// <summary>
+        ///    
+        /// </summary>
+        // typedef void (*CGerrorCallbackFunc)(void);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate void CgErrorCallbackFuncDelegate();
+
+        /// <summary>
+        ///    
+        /// </summary>
+        // typedef void (*CGerrorHandlerFunc)(CGcontext context, CGerror err, void *data);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate void CgErrorHandlerFuncDelegate(IntPtr context, ErrorType err, IntPtr data);
+
+        /// <summary>
+        /// 
+        /// </summary>
+        // typedef void (*CGIncludeCallbackFunc)( CGcontext context, const char *filename );
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate void CgIncludeCallbackFunc(IntPtr context, string filename);
+
+        /// <summary>
+        /// 
+        /// </summary>
+        // typedef CGbool (*CGstatecallback)(CGstateassignment);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        public delegate bool CgStateCallbackDelegate(IntPtr cGstateassignment);
+
+        #endregion Delegates
+
+        #region Methods
+
+        #region Public Static Methods
+
+        public static Behavior GetBehavior(string behaviorString)
+        {
+            return CgNativeMethods.cgGetBehavior(behaviorString);
+        }
+
+        public static string GetBehaviorString(Behavior behavior)
+        {
+            return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetBehaviorString(behavior));
+        }
+
+        public static Domain GetDomain(string domainString)
+        {
+            return CgNativeMethods.cgGetDomain(domainString);
+        }
+
+        public static string GetDomainString(Domain domain)
+        {
+            return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetDomainString(domain));
+        }
+
+        public static int GetEnum(string enumString)
+        {
+            return CgNativeMethods.cgGetEnum(enumString);
+        }
+
+        public static string GetEnumString(int en)
+        {
+            return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetEnumString(en));
+        }
+
+        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)
+        {
+            return CgNativeMethods.cgGetErrorString(error);
+        }
+
+        public static ErrorType GetFirstError()
+        {
+            return CgNativeMethods.cgGetFirstError();
+        }
+
+        public static string GetLastErrorString(out ErrorType error)
+        {
+            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);
+        }
+
+        public static int GetNumParentTypes(ParameterType type)
+        {
+            return CgNativeMethods.cgGetNumParentTypes(type);
+        }
+
+        public static int GetNumSupportedProfiles()
+        {
+            return CgNativeMethods.cgGetNumSupportedProfiles();
+        }
+
+        public static ParameterClass GetParameterClassEnum(string pString)
+        {
+            return CgNativeMethods.cgGetParameterClassEnum(pString);
+        }
+
+        public static string GetParameterClassString(ParameterClass pc)
+        {
+            return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetParameterClassString(pc));
+        }
+
+        public static ParameterType GetParentType(ParameterType type, int index)
+        {
+            return CgNativeMethods.cgGetParentType(type, index);
+        }
+
+        public static ProfileType GetProfile(string profile)
+        {
+            return CgNativeMethods.cgGetProfile(profile);
+        }
+
+        public static Domain GetProfileDomain(ProfileType profile)
+        {
+            return CgNativeMethods.cgGetProfileDomain(profile);
+        }
+
+        public static bool GetProfileProperty(ProfileType profile, Query query)
+        {
+            return CgNativeMethods.cgGetProfileProperty(profile, query);
+        }
+
+        public static string GetProfileString(ProfileType profile)
+        {
+            return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetProfileString(profile));
+        }
+
+        public static int GetProgramBufferMaxIndex(ProfileType profile)
+        {
+            return CgNativeMethods.cgGetProgramBufferMaxIndex(profile);
+        }
+
+        public static int GetProgramBufferMaxSize(ProfileType profile)
+        {
+            return CgNativeMethods.cgGetProgramBufferMaxSize(profile);
+        }
+
+        public static ResourceType GetResource(string resourceName)
+        {
+            return CgNativeMethods.cgGetResource(resourceName);
+        }
+
+        public static string GetResourceString(ResourceType resource)
+        {
+            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));
+        }
+
+        public static ProfileType GetSupportedProfile(int index)
+        {
+            return CgNativeMethods.cgGetSupportedProfile(index);
+        }
+
+        public static ParameterType GetType(string typeString)
+        {
+            return CgNativeMethods.cgGetType(typeString);
+        }
+
+        public static ParameterType GetTypeBase(ParameterType type)
+        {
+            return CgNativeMethods.cgGetTypeBase(type);
+        }
+
+        public static ParameterClass GetTypeClass(ParameterType type)
+        {
+            return CgNativeMethods.cgGetTypeClass(type);
+        }
+
+        public static bool GetTypeSizes(ParameterType type, out int nrows, out int ncols)
+        {
+            return CgNativeMethods.cgGetTypeSizes(type, out nrows, out ncols);
+        }
+
+        public static string GetTypeString(ParameterType type)
+        {
+            return Marshal.PtrToStringAnsi(CgNativeMethods.cgGetTypeString(type));
+        }
+
+        public static bool IsInterfaceType(ParameterType type)
+        {
+            return CgNativeMethods.cgIsInterfaceType(type);
+        }
+
+        public static bool IsParentType(ParameterType parent, int child)
+        {
+            return CgNativeMethods.cgIsParentType(parent, child);
+        }
+
+        public static bool IsProfileSupported(ProfileType profile)
+        {
+            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)
+            {
+                var retValue = new bool[count];
+                unsafe
+                {
+                    var ii = (int*)values;
+                    for (int i = 0; i < count; i++)
+                    {
+                        retValue[i] = ii[i] == CgNativeMethods.CgTrue;
+                    }
+                }
+
+                return retValue;
+            }
+
+            return null;
+        }
+
+        internal static unsafe string[] IntPtrToStringArray(IntPtr ptr)
+        {
+            if (ptr == IntPtr.Zero)
+            {
+                return null;
+            }
+
+            var byteArray = (byte**)ptr;
+            var lines = new List<string>();
+            var buffer = new List<byte>();
+
+            for (; ; )
+            {
+                byte* b = *byteArray;
+                for (; ; )
+                {
+                    if (b == null || *b == '\0')
+                    {
+                        if (buffer.Count > 0)
+                        {
+                            char[] cc = Encoding.ASCII.GetChars(buffer.ToArray());
+                            lines.Add(new string(cc));
+                            buffer.Clear();
+                        }
+                        break;
+                    }
+
+                    buffer.Add(*b);
+                    b++;
+                }
+
+                byteArray++;
+
+                if (b == null)
+                {
+                    break;
+                }
+            }
+
+            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
+    }
+}
+ďťż/*
+ CgNet v1.0
+ Copyright (c) 2010 Tobias Bohnen
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ software and associated documentation files (the "Software"), to deal in the Software
+ without restriction, including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
+ to whom the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all copies or
+ substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ */
+namespace CgNet
+{
+    #region Enumerations
+
+    public enum AutoCompileMode
+    {
+        CompileManual = 4114,
+        CompileImmediate = 4115,
+        CompileLazy = 4116,
+    }
+
+    public enum Behavior
+    {
+        Unknown = 0,
+        Latest = 1, /* latest behavior supported at runtime      */
+        Behavior2200 = 1000, /* default behavior                          */
+        Behavior3000 = 2000,
+        Current = Behavior3000 /* latest behavior supported at compile time */
+    }
+
+    public enum BufferAccess
+    {
+        Read = 0,
+        Write = 1,
+        ReadWrite = 2,
+        WriteDiscard = 3,
+        WriteNoOverwrite = 4
+    }
+
+    public enum BufferUsage
+    {
+        StreamDraw = 0,
+        StreamRead = 1,
+        StreamCopy = 2,
+        StaticDraw = 3,
+        StaticRead = 4,
+        StaticCopy = 5,
+        DynamicDraw = 6,
+        DynamicRead = 7,
+        DynamicCopy = 8
+    }
+
+    public enum CasePolicy
+    {
+        ForceUpperCasePolicy = 4136,
+        UnchangedCasePolicy = 4137,
+    }
+
+    public enum CgAll
+    {
+        Unknown = 4096,
+        In = 4097,
+        Out = 4098,
+        Inout = 4099,
+        Mixed = 4100,
+        Varying = 4101,
+        Uniform = 4102,
+        Constant = 4103,
+        ProgramSource = 4104, /* GetProgramString                       */
+        ProgramEntry = 4105, /* GetProgramString                       */
+        CompiledProgram = 4106, /* GetProgramString                       */
+        ProgramProfile = 4107, /* GetProgramString                       */
+        Global = 4108,
+        Program = 4109,
+        Default = 4110,
+        Error = 4111,
+        Source = 4112,
+        Object = 4113,
+        CompileManual = 4114,
+        CompileImmediate = 4115,
+        CompileLazy = 4116,
+        Current = 4117,
+        Literal = 4118,
+        Version = 4119, /* GetString                              */
+        RowMajor = 4120,
+        ColumnMajor = 4121,
+        Fragment = 4122, /* GetProgramInput and GetProgramOutput */
+        Vertex = 4123, /* GetProgramInput and GetProgramOutput */
+        Point = 4124, /* Geometry program GetProgramInput       */
+        Line = 4125, /* Geometry program GetProgramInput       */
+        LineAdj = 4126, /* Geometry program GetProgramInput       */
+        Triangle = 4127, /* Geometry program GetProgramInput       */
+        TriangleAdj = 4128, /* Geometry program GetProgramInput       */
+        PointOut = 4129, /* Geometry program GetProgramOutput      */
+        LineOut = 4130, /* Geometry program GetProgramOutput      */
+        TriangleOut = 4131, /* Geometry program GetProgramOutput      */
+        ImmediateParameterSetting = 4132,
+        DeferredParameterSetting = 4133,
+        NoLocksPolicy = 4134,
+        ThreadSafePolicy = 4135,
+        ForceUpperCasePolicy = 4136,
+        UnchangedCasePolicy = 4137,
+        IsOpenglProfile = 4138,
+        IsDirect3DProfile = 4139,
+        IsDirect3D8Profile = 4140,
+        IsDirect3D9Profile = 4141,
+        IsDirect3D10Profile = 4142,
+        IsVertexProfile = 4143,
+        IsFragmentProfile = 4144,
+        IsGeometryProfile = 4145,
+        IsTranslationProfile = 4146,
+        IsHLSLProfile = 4147,
+        IsGLSLProfile = 4148,
+        IsTessellationControlProfile = 4149,
+        IsTessellationEvaluationProfile = 4150,
+        Patch = 4152, /* GetProgramInput and GetProgramOutput */
+        IsDirect3D11Profile = 4153
+    }
+
+    public enum Domain
+    {
+        UnknownDomain = 0,
+        FirstDomain = 1,
+        VertexDomain = 1,
+        FragmentDomain = 2,
+        GeometryDomain = 3,
+        TessellationControlDomain = 4,
+        TessellationEvaluationDomain = 5
+    }
+
+    public enum ErrorType
+    {
+        NoError = 0,
+        CompilerError = 1,
+        InvalidParameterError = 2,
+        InvalidProfileError = 3,
+        ProgramLoadError = 4,
+        ProgramBindError = 5,
+        ProgramNotLoadedError = 6,
+        UnsupportedGLExtensionError = 7,
+        InvalidValueTypeError = 8,
+        NotMatrixParamError = 9,
+        InvalidEnumerantError = 10,
+        Not_4X4MatrixError = 11,
+        FileReadError = 12,
+        FileWriteError = 13,
+        NvparseError = 14,
+        MemoryAllocError = 15,
+        InvalidContextHandleError = 16,
+        InvalidProgramHandleError = 17,
+        InvalidParamHandleError = 18,
+        UnknownProfileError = 19,
+        VarArgError = 20,
+        InvalidDimensionError = 21,
+        ArrayParamError = 22,
+        OutOfArrayBoundsError = 23,
+        ConflictingTypesError = 24,
+        ConflictingParameterTypesError = 25,
+        ParameterIsNotSharedError = 26,
+        InvalidParameterVariabilityError = 27,
+        CannotDestroyParameterError = 28,
+        NotRootParameterError = 29,
+        ParametersDoNotMatchError = 30,
+        IsNotProgramParameterError = 31,
+        InvalidParameterTypeError = 32,
+        ParameterIsNotResizableArrayError = 33,
+        InvalidSizeError = 34,
+        BindCreatesCycleError = 35,
+        ArrayTypesDoNotMatchError = 36,
+        ArrayDimensionsDoNotMatchError = 37,
+        ArrayHasWrongDimensionError = 38,
+        TypeIsNotDefinedInProgramError = 39,
+        InvalidEffectHandleError = 40,
+        InvalidStateHandleError = 41,
+        InvalidStateAssignmentHandleError = 42,
+        InvalidPassHandleError = 43,
+        InvalidAnnotationHandleError = 44,
+        InvalidTechniqueHandleError = 45,
+        InvalidParameterHandleError = 46,
+        StateAssignmentTypeMismatchError = 47,
+        InvalidFunctionHandleError = 48,
+        InvalidTechniqueError = 49,
+        InvalidPointerError = 50,
+        NotEnoughDataError = 51,
+        NonNumericParameterError = 52,
+        ArraySizeMismatchError = 53,
+        CannotSetNonUniformParameterError = 54,
+        DuplicateNameError = 55,
+        InvalidObjHandleError = 56,
+        InvalidBufferHandleError = 57,
+        BufferIndexOutOfRangeError = 58,
+        BufferAlreadyMappedError = 59,
+        BufferUpdateNotAllowedError = 60,
+        GlslgUncombinedLoadError = 61,
+        ErrorMax
+    }
+
+    public enum LockingPolicy
+    {
+        NoLocksPolicy = 4134,
+        ThreadSafePolicy = 4135,
+    }
+
+    public enum Order
+    {
+        ColumnMajor = 4121,
+        RowMajor = 4120
+    }
+
+    public enum ParameterClass
+    {
+        Unknown = 0,
+        Scalar = 1,
+        Vector = 2,
+        Matrix = 3,
+        Struct = 4,
+        Array = 5,
+        Sampler = 6,
+        Object = 7
+    }
+
+    public enum ParameterDirection
+    {
+        In = 4097,
+        Out = 4098,
+        Inout = 4099,
+        Error = 4111,
+    }
+
+    public enum ParameterSettingMode
+    {
+        Immediate = 4132,
+        Deferred = 4133
+    }
+
+    public enum ParameterType
+    {
+        UnknownType = 0,
+        Array = 2,
+        String = 1135,
+        Struct = 1,
+        TypelessStruct = 3,
+        Texture = 1137,
+        PixelshaderType = 1142,
+        ProgramType = 1136,
+        VertexshaderType = 1141,
+        TypeStartEnum = 1024,
+        Sampler = 1143,
+        Sampler1D = 1065,
+        Sampler1Darray = 1138,
+        Sampler1Dshadow = 1313,
+        Sampler2D = 1066,
+        Sampler2Darray = 1139,
+        Sampler2Dshadow = 1314,
+        Sampler3D = 1067,
+        Samplerbuf = 1144,
+        Samplercube = 1069,
+        Samplercubearray = 1140,
+        Samplerrect = 1068,
+        Samplerrectshadow = 1315,
+        Bool = 1114,
+        Bool1 = 1115,
+        Bool2 = 1116,
+        Bool3 = 1117,
+        Bool4 = 1118,
+        Bool1X1 = 1119,
+        Bool1X2 = 1120,
+        Bool1X3 = 1121,
+        Bool1X4 = 1122,
+        Bool2X1 = 1123,
+        Bool2X2 = 1124,
+        Bool2X3 = 1125,
+        Bool2X4 = 1126,
+        Bool3X1 = 1127,
+        Bool3X2 = 1128,
+        Bool3X3 = 1129,
+        Bool3X4 = 1130,
+        Bool4X1 = 1131,
+        Bool4X2 = 1132,
+        Bool4X3 = 1133,
+        Bool4X4 = 1134,
+        Char = 1166,
+        Char1 = 1167,
+        Char2 = 1168,
+        Char3 = 1169,
+        Char4 = 1170,
+        Char1X1 = 1171,
+        Char1X2 = 1172,
+        Char1X3 = 1173,
+        Char1X4 = 1174,
+        Char2X1 = 1175,
+        Char2X2 = 1176,
+        Char2X3 = 1177,
+        Char2X4 = 1178,
+        Char3X1 = 1179,
+        Char3X2 = 1180,
+        Char3X3 = 1181,
+        Char3X4 = 1182,
+        Char4X1 = 1183,
+        Char4X2 = 1184,
+        Char4X3 = 1185,
+        Char4X4 = 1186,
+        Double = 1145,
+        Double1 = 1146,
+        Double2 = 1147,
+        Double3 = 1148,
+        Double4 = 1149,
+        Double1X1 = 1150,
+        Double1X2 = 1151,
+        Double1X3 = 1152,
+        Double1X4 = 1153,
+        Double2X1 = 1154,
+        Double2X2 = 1155,
+        Double2X3 = 1156,
+        Double2X4 = 1157,
+        Double3X1 = 1158,
+        Double3X2 = 1159,
+        Double3X3 = 1160,
+        Double3X4 = 1161,
+        Double4X1 = 1162,
+        Double4X2 = 1163,
+        Double4X3 = 1164,
+        Double4X4 = 1165,
+        Fixed = 1070,
+        Fixed1 = 1092,
+        Fixed2 = 1071,
+        Fixed3 = 1072,
+        Fixed4 = 1073,
+        Fixed1X1 = 1074,
+        Fixed1X2 = 1075,
+        Fixed1X3 = 1076,
+        Fixed1X4 = 1077,
+        Fixed2X1 = 1078,
+        Fixed2X2 = 1079,
+        Fixed2X3 = 1080,
+        Fixed2X4 = 1081,
+        Fixed3X1 = 1082,
+        Fixed3X2 = 1083,
+        Fixed3X3 = 1084,
+        Fixed3X4 = 1085,
+        Fixed4X1 = 1086,
+        Fixed4X2 = 1087,
+        Fixed4X3 = 1088,
+        Fixed4X4 = 1089,
+        Float = 1045,
+        Float1 = 1091,
+        Float2 = 1046,
+        Float3 = 1047,
+        Float4 = 1048,
+        Float1X1 = 1049,
+        Float1X2 = 1050,
+        Float1X3 = 1051,
+        Float1X4 = 1052,
+        Float2X1 = 1053,
+        Float2X2 = 1054,
+        Float2X3 = 1055,
+        Float2X4 = 1056,
+        Float3X1 = 1057,
+        Float3X2 = 1058,
+        Float3X3 = 1059,
+        Float3X4 = 1060,
+        Float4X1 = 1061,
+        Float4X2 = 1062,
+        Float4X3 = 1063,
+        Float4X4 = 1064,
+        Half = 1025,
+        Half1 = 1090,
+        Half2 = 1026,
+        Half3 = 1027,
+        Half4 = 1028,
+        Half1X1 = 1029,
+        Half1X2 = 1030,
+        Half1X3 = 1031,
+        Half1X4 = 1032,
+        Half2X1 = 1033,
+        Half2X2 = 1034,
+        Half2X3 = 1035,
+        Half2X4 = 1036,
+        Half3X1 = 1037,
+        Half3X2 = 1038,
+        Half3X3 = 1039,
+        Half3X4 = 1040,
+        Half4X1 = 1041,
+        Half4X2 = 1042,
+        Half4X3 = 1043,
+        Half4X4 = 1044,
+        Int = 1093,
+        Int1 = 1094,
+        Int2 = 1095,
+        Int3 = 1096,
+        Int4 = 1097,
+        Int1X1 = 1098,
+        Int1X2 = 1099,
+        Int1X3 = 1100,
+        Int1X4 = 1101,
+        Int2X1 = 1102,
+        Int2X2 = 1103,
+        Int2X3 = 1104,
+        Int2X4 = 1105,
+        Int3X1 = 1106,
+        Int3X2 = 1107,
+        Int3X3 = 1108,
+        Int3X4 = 1109,
+        Int4X1 = 1110,
+        Int4X2 = 1111,
+        Int4X3 = 1112,
+        Int4X4 = 1113,
+        Long = 1271,
+        Long1 = 1272,
+        Long2 = 1273,
+        Long3 = 1274,
+        Long4 = 1275,
+        Long1X1 = 1276,
+        Long1X2 = 1277,
+        Long1X3 = 1278,
+        Long1X4 = 1279,
+        Long2X1 = 1280,
+        Long2X2 = 1281,
+        Long2X3 = 1282,
+        Long2X4 = 1283,
+        Long3X1 = 1284,
+        Long3X2 = 1285,
+        Long3X3 = 1286,
+        Long3X4 = 1287,
+        Long4X1 = 1288,
+        Long4X2 = 1289,
+        Long4X3 = 1290,
+        Long4X4 = 1291,
+        Short = 1208,
+        Short1 = 1209,
+        Short2 = 1210,
+        Short3 = 1211,
+        Short4 = 1212,
+        Short1X1 = 1213,
+        Short1X2 = 1214,
+        Short1X3 = 1215,
+        Short1X4 = 1216,
+        Short2X1 = 1217,
+        Short2X2 = 1218,
+        Short2X3 = 1219,
+        Short2X4 = 1220,
+        Short3X1 = 1221,
+        Short3X2 = 1222,
+        Short3X3 = 1223,
+        Short3X4 = 1224,
+        Short4X1 = 1225,
+        Short4X2 = 1226,
+        Short4X3 = 1227,
+        Short4X4 = 1228,
+        Uchar = 1187,
+        Uchar1 = 1188,
+        Uchar2 = 1189,
+        Uchar3 = 1190,
+        Uchar4 = 1191,
+        Uchar1X1 = 1192,
+        Uchar1X2 = 1193,
+        Uchar1X3 = 1194,
+        Uchar1X4 = 1195,
+        Uchar2X1 = 1196,
+        Uchar2X2 = 1197,
+        Uchar2X3 = 1198,
+        Uchar2X4 = 1199,
+        Uchar3X1 = 1200,
+        Uchar3X2 = 1201,
+        Uchar3X3 = 1202,
+        Uchar3X4 = 1203,
+        Uchar4X1 = 1204,
+        Uchar4X2 = 1205,
+        Uchar4X3 = 1206,
+        Uchar4X4 = 1207,
+        Uint = 1250,
+        Uint1 = 1251,
+        Uint2 = 1252,
+        Uint3 = 1253,
+        Uint4 = 1254,
+        Uint1X1 = 1255,
+        Uint1X2 = 1256,
+        Uint1X3 = 1257,
+        Uint1X4 = 1258,
+        Uint2X1 = 1259,
+        Uint2X2 = 1260,
+        Uint2X3 = 1261,
+        Uint2X4 = 1262,
+        Uint3X1 = 1263,
+        Uint3X2 = 1264,
+        Uint3X3 = 1265,
+        Uint3X4 = 1266,
+        Uint4X1 = 1267,
+        Uint4X2 = 1268,
+        Uint4X3 = 1269,
+        Uint4X4 = 1270,
+        Ulong = 1292,
+        Ulong1 = 1293,
+        Ulong2 = 1294,
+        Ulong3 = 1295,
+        Ulong4 = 1296,
+        Ulong1X1 = 1297,
+        Ulong1X2 = 1298,
+        Ulong1X3 = 1299,
+        Ulong1X4 = 1300,
+        Ulong2X1 = 1301,
+        Ulong2X2 = 1302,
+        Ulong2X3 = 1303,
+        Ulong2X4 = 1304,
+        Ulong3X1 = 1305,
+        Ulong3X2 = 1306,
+        Ulong3X3 = 1307,
+        Ulong3X4 = 1308,
+        Ulong4X1 = 1309,
+        Ulong4X2 = 1310,
+        Ulong4X3 = 1311,
+        Ulong4X4 = 1312,
+        Ushort = 1229,
+        Ushort1 = 1230,
+        Ushort2 = 1231,
+        Ushort3 = 1232,
+        Ushort4 = 1233,
+        Ushort1X1 = 1234,
+        Ushort1X2 = 1235,
+        Ushort1X3 = 1236,
+        Ushort1X4 = 1237,
+        Ushort2X1 = 1238,
+        Ushort2X2 = 1239,
+        Ushort2X3 = 1240,
+        Ushort2X4 = 1241,
+        Ushort3X1 = 1242,
+        Ushort3X2 = 1243,
+        Ushort3X3 = 1244,
+        Ushort3X4 = 1245,
+        Ushort4X1 = 1246,
+        Ushort4X2 = 1247,
+        Ushort4X3 = 1248,
+        Ushort4X4 = 1249
+    }
+
+    public enum ProfileType
+    {
+        Unknown = 6145,
+        Vp20 = 6146,
+        Fp20 = 6147,
+        Vp30 = 6148,
+        Fp30 = 6149,
+        Arbvp1 = 6150,
+        Fp40 = 6151,
+        Arbfp1 = 7000,
+        Vp40 = 7001,
+        Glslv = 7007,
+        Glslf = 7008,
+        Glslg = 7016,
+        Glslc = 7009,
+        GPUFp = 7010, /* Deprecated alias for CG_PROFILE_GP4FP                    */
+        GPUVp = 7011, /* Deprecated alias for CG_PROFILE_GP4VP                    */
+        GPUGp = 7012, /* Deprecated alias for CG_PROFILE_GP4GP                    */
+        Gp4Fp = 7010,
+        Gp4Vp = 7011,
+        Gp4Gp = 7012,
+        Gp5Fp = 7017, /* NV_gpu_program5                                          */
+        Gp5Vp = 7018, /* NV_gpu_program5                                          */
+        Gp5Gp = 7019, /* NV_gpu_program5                                          */
+        Gp5Tcp = 7020, /* NV_tessellation_program5 Tessellation control program    */
+        Gp5Tep = 7021, /* NV_tessellation_program5 Tessellation evaluation program */
+        Vs11 = 6153,
+        Vs20 = 6154,
+        Vs2X = 6155,
+        Vs2Sw = 6156,
+        Vs30 = 6157,
+        Hlslv = 6158,
+        Ps11 = 6159,
+        Ps12 = 6160,
+        Ps13 = 6161,
+        Ps20 = 6162,
+        Ps2X = 6163,
+        Ps2Sw = 6164,
+        Ps30 = 6165,
+        Hlslf = 6166,
+        Vs40 = 6167,
+        Ps40 = 6168,
+        Gs40 = 6169,
+        Vs50 = 6170,
+        Ps50 = 6171,
+        Gs50 = 6172,
+        Hs50 = 6173,
+        Ds50 = 6174,
+        Generic = 7002
+    }
+
+    public enum ProgramInput
+    {
+        Fragment = 4122, /* GetProgramInput and GetProgramOutput */
+        Vertex = 4123, /* GetProgramInput and GetProgramOutput */
+        Point = 4124, /* Geometry program GetProgramInput       */
+        Line = 4125, /* Geometry program GetProgramInput       */
+        LineAdj = 4126, /* Geometry program GetProgramInput       */
+        Triangle = 4127, /* Geometry program GetProgramInput       */
+        TriangleAdj = 4128, /* Geometry program GetProgramInput       */
+        PointOut = 4129, /* Geometry program GetProgramOutput      */
+        LineOut = 4130, /* Geometry program GetProgramOutput      */
+        TriangleOut = 4131, /* Geometry program GetProgramOutput      */
+        Patch = 4152, /* GetProgramInput and GetProgramOutput */
+    }
+
+    public enum ProgramNamespace
+    {
+        Global = 4108,
+        Program = 4109,
+    }
+
+    public enum ProgramOutput
+    {
+        Fragment = 4122, /* GetProgramInput and GetProgramOutput */
+        Vertex = 4123, /* GetProgramInput and GetProgramOutput */
+        Point = 4124, /* Geometry program GetProgramInput       */
+        Line = 4125, /* Geometry program GetProgramInput       */
+        LineAdj = 4126, /* Geometry program GetProgramInput       */
+        Triangle = 4127, /* Geometry program GetProgramInput       */
+        TriangleAdj = 4128, /* Geometry program GetProgramInput       */
+        PointOut = 4129, /* Geometry program GetProgramOutput      */
+        LineOut = 4130, /* Geometry program GetProgramOutput      */
+        TriangleOut = 4131, /* Geometry program GetProgramOutput      */
+        Patch = 4152, /* GetProgramInput and GetProgramOutput */
+    }
+
+    public enum ProgramType
+    {
+        Source = 4112,
+        Object = 4113
+    }
+
+    public enum Query
+    {
+        IsOpenglProfile = 4138,
+        IsDirect3DProfile = 4139,
+        IsDirect3D8Profile = 4140,
+        IsDirect3D9Profile = 4141,
+        IsDirect3D10Profile = 4142,
+        IsVertexProfile = 4143,
+        IsFragmentProfile = 4144,
+        IsGeometryProfile = 4145,
+        IsTranslationProfile = 4146,
+        IsHLSLProfile = 4147,
+        IsGLSLProfile = 4148,
+        IsTessellationControlProfile = 4149,
+        IsTessellationEvaluationProfile = 4150,
+    }
+
+    public enum ResourceType
+    {
+        TexUnit0 = 2048,
+        TexUnit1 = 2049,
+        TexUnit2 = 2050,
+        TexUnit3 = 2051,
+        TexUnit4 = 2052,
+        TexUnit5 = 2053,
+        TexUnit6 = 2054,
+        TexUnit7 = 2055,
+        TexUnit8 = 2056,
+        TexUnit9 = 2057,
+        TexUnit10 = 2058,
+        TexUnit11 = 2059,
+        TexUnit12 = 2060,
+        TexUnit13 = 2061,
+        TexUnit14 = 2062,
+        TexUnit15 = 2063,
+        TexUnit16 = 4624,
+        TexUnit17 = 4625,
+        TexUnit18 = 4626,
+        TexUnit19 = 4627,
+        TexUnit20 = 4628,
+        TexUnit21 = 4629,
+        TexUnit22 = 4630,
+        TexUnit23 = 4631,
+        TexUnit24 = 4632,
+        TexUnit25 = 4633,
+        TexUnit26 = 4634,
+        TexUnit27 = 4635,
+        TexUnit28 = 4636,
+        TexUnit29 = 4637,
+        TexUnit30 = 4638,
+        TexUnit31 = 4639,
+        Buffer0 = 2064,
+        Buffer1 = 2065,
+        Buffer2 = 2066,
+        Buffer3 = 2067,
+        Buffer4 = 2068,
+        Buffer5 = 2069,
+        Buffer6 = 2070,
+        Buffer7 = 2071,
+        Buffer8 = 2072,
+        Buffer9 = 2073,
+        Buffer10 = 2074,
+        Buffer11 = 2075,
+        Attr0 = 2113,
+        Attr1 = 2114,
+        Attr2 = 2115,
+        Attr3 = 2116,
+        Attr4 = 2117,
+        Attr5 = 2118,
+        Attr6 = 2119,
+        Attr7 = 2120,
+        Attr8 = 2121,
+        Attr9 = 2122,
+        Attr10 = 2123,
+        Attr11 = 2124,
+        Attr12 = 2125,
+        Attr13 = 2126,
+        Attr14 = 2127,
+        Attr15 = 2128,
+        C = 2178,
+        Tex0 = 2179,
+        Tex1 = 2180,
+        Tex2 = 2181,
+        Tex3 = 2192,
+        Tex4 = 2193,
+        Tex5 = 2194,
+        Tex6 = 2195,
+        Tex7 = 2196,
+        Hpos = 2243,
+        Col0 = 2245,
+        Col1 = 2246,
+        Col2 = 2247,
+        Col3 = 2248,
+        Psiz = 2309,
+        Clp0 = 2310,
+        Clp1 = 2311,
+        Clp2 = 2312,
+        Clp3 = 2313,
+        Clp4 = 2314,
+        Clp5 = 2315,
+        Wpos = 2373,
+        Pointcoord = 2374,
+        Position0 = 2437,
+        Position1 = 2438,
+        Position2 = 2439,
+        Position3 = 2440,
+        Position4 = 2441,
+        Position5 = 2442,
+        Position6 = 2443,
+        Position7 = 2444,
+        Position8 = 2445,
+        Position9 = 2446,
+        Position10 = 2447,
+        Position11 = 2448,
+        Position12 = 2449,
+        Position13 = 2450,
+        Position14 = 2451,
+        Position15 = 2452,
+        Diffuse0 = 2501,
+        Tangent0 = 2565,
+        Tangent1 = 2566,
+        Tangent2 = 2567,
+        Tangent3 = 2568,
+        Tangent4 = 2569,
+        Tangent5 = 2570,
+        Tangent6 = 2571,
+        Tangent7 = 2572,
+        Tangent8 = 2573,
+        Tangent9 = 2574,
+        Tangent10 = 2575,
+        Tangent11 = 2576,
+        Tangent12 = 2577,
+        Tangent13 = 2578,
+        Tangent14 = 2579,
+        Tangent15 = 2580,
+        Specular0 = 2629,
+        BlendIndices0 = 2693,
+        BlendIndices1 = 2694,
+        BlendIndices2 = 2695,
+        BlendIndices3 = 2696,
+        BlendIndices4 = 2697,
+        BlendIndices5 = 2698,
+        BlendIndices6 = 2699,
+        BlendIndices7 = 2700,
+        BlendIndices8 = 2701,
+        BlendIndices9 = 2702,
+        BlendIndices10 = 2703,
+        BlendIndices11 = 2704,
+        BlendIndices12 = 2705,
+        BlendIndices13 = 2706,
+        BlendIndices14 = 2707,
+        BlendIndices15 = 2708,
+        Color0 = 2757,
+        Color1 = 2758,
+        Color2 = 2759,
+        Color3 = 2760,
+        Color4 = 2761,
+        Color5 = 2762,
+        Color6 = 2763,
+        Color7 = 2764,
+        Color8 = 2765,
+        Color9 = 2766,
+        Color10 = 2767,
+        Color11 = 2768,
+        Color12 = 2769,
+        Color13 = 2770,
+        Color14 = 2771,
+        Color15 = 2772,
+        PSize0 = 2821,
+        PSize1 = 2822,
+        PSize2 = 2823,
+        PSize3 = 2824,
+        PSize4 = 2825,
+        PSize5 = 2826,
+        PSize6 = 2827,
+        PSize7 = 2828,
+        PSize8 = 2829,
+        PSize9 = 2830,
+        PSize10 = 2831,
+        PSize11 = 2832,
+        PSize12 = 2833,
+        PSize13 = 2834,
+        PSize14 = 2835,
+        PSize15 = 2836,
+        Binormal0 = 2885,
+        Binormal1 = 2886,
+        Binormal2 = 2887,
+        Binormal3 = 2888,
+        Binormal4 = 2889,
+        Binormal5 = 2890,
+        Binormal6 = 2891,
+        Binormal7 = 2892,
+        Binormal8 = 2893,
+        Binormal9 = 2894,
+        Binormal10 = 2895,
+        Binormal11 = 2896,
+        Binormal12 = 2897,
+        Binormal13 = 2898,
+        Binormal14 = 2899,
+        Binormal15 = 2900,
+        Fog0 = 2917,
+        Fog1 = 2918,
+        Fog2 = 2919,
+        Fog3 = 2920,
+        Fog4 = 2921,
+        Fog5 = 2922,
+        Fog6 = 2923,
+        Fog7 = 2924,
+        Fog8 = 2925,
+        Fog9 = 2926,
+        Fog10 = 2927,
+        Fog11 = 2928,
+        Fog12 = 2929,
+        Fog13 = 2930,
+        Fog14 = 2931,
+        Fog15 = 2932,
+        Depth0 = 2933,
+        Depth1 = 2934,
+        Depth2 = 2935,
+        Depth3 = 2936,
+        Depth4 = 2937,
+        Depth5 = 2938,
+        Depth6 = 2939,
+        Depth7 = 2940,
+        Depth8 = 2941,
+        Depth9 = 2942,
+        Depth10 = 2943,
+        Depth11 = 2944,
+        Depth12 = 2945,
+        Depth13 = 2946,
+        Depth14 = 2947,
+        Depth15 = 2948,
+        Sample0 = 2949,
+        Sample1 = 2950,
+        Sample2 = 2951,
+        Sample3 = 2952,
+        Sample4 = 2953,
+        Sample5 = 2954,
+        Sample6 = 2955,
+        Sample7 = 2956,
+        Sample8 = 2957,
+        Sample9 = 2958,
+        Sample10 = 2959,
+        Sample11 = 2960,
+        Sample12 = 2961,
+        Sample13 = 2962,
+        Sample14 = 2963,
+        Sample15 = 2964,
+        BlendWeight0 = 3028,
+        BlendWeight1 = 3029,
+        BlendWeight2 = 3030,
+        BlendWeight3 = 3031,
+        BlendWeight4 = 3032,
+        BlendWeight5 = 3033,
+        BlendWeight6 = 3034,
+        BlendWeight7 = 3035,
+        BlendWeight8 = 3036,
+        BlendWeight9 = 3037,
+        BlendWeight10 = 3038,
+        BlendWeight11 = 3039,
+        BlendWeight12 = 3040,
+        BlendWeight13 = 3041,
+        BlendWeight14 = 3042,
+        BlendWeight15 = 3043,
+        Normal0 = 3092,
+        Normal1 = 3093,
+        Normal2 = 3094,
+        Normal3 = 3095,
+        Normal4 = 3096,
+        Normal5 = 3097,
+        Normal6 = 3098,
+        Normal7 = 3099,
+        Normal8 = 3100,
+        Normal9 = 3101,
+        Normal10 = 3102,
+        Normal11 = 3103,
+        Normal12 = 3104,
+        Normal13 = 3105,
+        Normal14 = 3106,
+        Normal15 = 3107,
+        Fogcoord = 3156,
+        TexCoord0 = 3220,
+        TexCoord1 = 3221,
+        TexCoord2 = 3222,
+        TexCoord3 = 3223,
+        TexCoord4 = 3224,
+        TexCoord5 = 3225,
+        TexCoord6 = 3226,
+        TexCoord7 = 3227,
+        TexCoord8 = 3228,
+        TexCoord9 = 3229,
+        TexCoord10 = 3230,
+        TexCoord11 = 3231,
+        TexCoord12 = 3232,
+        TexCoord13 = 3233,
+        TexCoord14 = 3234,
+        TexCoord15 = 3235,
+        CombinerConst0 = 3284,
+        CombinerConst1 = 3285,
+        CombinerStageConst0 = 3286,
+        CombinerStageConst1 = 3287,
+        OffsetTextureMatrix = 3288,
+        OffsetTextureScale = 3289,
+        OffsetTextureBias = 3290,
+        ConstEye = 3291,
+        Coverage = 3292,
+        Tessfactor = 3255,
+        GLSLUniform = 3300,
+        GLSLAttrib = 3301,
+        Env = 3302,
+        HLSLUniform = 3559,
+        HLSLVarying = 3560,
+        SamplerRes = 3561,
+        LastCol0 = 4400,
+        LastCol1 = 4401,
+        LastCol2 = 4402,
+        LastCol3 = 4403,
+        LastCol4 = 4404,
+        LastCol5 = 4405,
+        LastCol6 = 4406,
+        LastCol7 = 4407,
+        Face = 4410,
+        PrimitiveId = 4411,
+        InstanceId = 4412,
+        SampleId = 4413,
+        VertexId = 4414,
+        Layer = 4415,
+        SampleMask = 4416,
+        ControlPointId = 4417,
+        Edgetess = 4418,
+        Innertess = 4419,
+        Undefined = 3256
+    }
+
+    public enum SourceType
+    {
+        ProgramSource = 4104, /* GetProgramString                       */
+        ProgramEntry = 4105, /* GetProgramString                       */
+        CompiledProgram = 4106, /* GetProgramString                       */
+        ProgramProfile = 4107, /* GetProgramString                       */
+    }
+
+    #endregion Enumerations
+}

CgNet/CgNativeMethods.cs

+/*
+MIT License
+Copyright Š2003-2006 Tao Framework Team
+http://www.taoframework.com
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+namespace CgNet
+{
+    using System;
+    using System.Runtime.InteropServices;
+    using System.Security;
+
+    /// <summary>
+    ///     Cg core runtime binding for .NET, implementing Cg 1.4.1.
+    /// </summary>
+    /// <remarks>
+    ///     Binds functions and definitions in cg.dll or libcg.so.
+    /// </remarks>
+    internal static class CgNativeMethods
+    {
+        #region Fields
+
+        internal const int CgFalse = 0;
+        internal const int CgTrue = 1;
+
+        private const string CgNativeLibrary = "cg.dll";
+        private const CallingConvention Convention = CallingConvention.Cdecl;
+
+        #endregion Fields
+
+        #region Methods
+
+        #region Internal Static Methods
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern void cgAddStateEnumerant(IntPtr state, string name, int value);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        [return: MarshalAs(UnmanagedType.Bool)]
+        internal static extern bool cgCallStateResetCallback(IntPtr stateassignment);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        [return: MarshalAs(UnmanagedType.Bool)]
+        internal static extern bool cgCallStateSetCallback(IntPtr stateassignment);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        [return: MarshalAs(UnmanagedType.Bool)]
+        internal static extern bool cgCallStateValidateCallback(IntPtr stateassignment);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCombinePrograms(int n, IntPtr[] progs);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCombinePrograms2(IntPtr exe1, IntPtr exe2);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCombinePrograms3(IntPtr exe1, IntPtr exe2, IntPtr exe3);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCombinePrograms4(IntPtr exe1, IntPtr exe2, IntPtr exe3, IntPtr exe4);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCombinePrograms5(IntPtr exe1, IntPtr exe2, IntPtr exe3, IntPtr exe4, IntPtr exe5);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern void cgCompileProgram(IntPtr prog);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern void cgConnectParameter(IntPtr from, IntPtr to);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCopyEffect(IntPtr effect);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCopyProgram(IntPtr program);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateArraySamplerState(IntPtr context, string name, ParameterType type, int nelems);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateArrayState(IntPtr context, string name, ParameterType type, int nelems);
+
+        // CG_API CGbuffer CGENTRY cgCreateBuffer(CGcontext context, int size, const void *data, CGbufferusage bufferUsage);
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateBuffer(IntPtr context, int size, IntPtr data, BufferUsage bufferUsage);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateContext();
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateEffect(IntPtr context, string code, string[] args);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateEffectAnnotation(IntPtr effect, string name, ParameterType type);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateEffectFromFile(IntPtr context, string filename, string[] args);
+
+        //CG_API CGparameter CGENTRY cgCreateEffectParameter(CGeffect effect, const char *name, CGtype type);
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateEffectParameter(IntPtr context, string name, ParameterType type);
+
+        //CG_API CGparameter CGENTRY cgCreateEffectParameterArray(CGeffect effect, const char *name, CGtype type, int length);
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateEffectParameterArray(IntPtr effect, string name, ParameterType type, int length);
+
+        //CG_API CGparameter CGENTRY cgCreateEffectParameterMultiDimArray(CGeffect effect, const char *name, CGtype type, int dim, const int *lengths);
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateEffectParameterMultiDimArray(IntPtr effect, string name, ParameterType type, int dim, int[] lengths);
+
+        //CG_API CGobj CGENTRY cgCreateObj(CGcontext context, CGenum program_type, const char *source, CGprofile profile, const char **args);
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateObj(IntPtr context, ProgramType programType, string source, ProfileType profile, string[] args);
+
+        //CG_API CGobj CGENTRY cgCreateObjFromFile(CGcontext context, CGenum program_type, const char *source_file, CGprofile profile, const char **args);
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateObjFromFile(IntPtr context, ProgramType programType, string sourceFile, ProfileType profile, string[] args);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateParameter(IntPtr context, ParameterType type);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateParameterAnnotation(IntPtr param, string name, ParameterType type);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateParameterArray(IntPtr context, ParameterType type, int length);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateParameterMultiDimArray(IntPtr context, ParameterType type, int dim, [In] int[] lengths);
+
+        //CG_API CGpass CGENTRY cgCreatePass(CGtechnique tech, const char *name);
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreatePass(IntPtr tech, string name);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreatePassAnnotation(IntPtr pass, string name, ParameterType type);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateProgram(IntPtr context, ProgramType type, string source, ProfileType profile, string entry, string[] args);
+
+        // CG_API CGannotation CGENTRY cgCreateProgramAnnotation(CGprogram program, const char *name, CGtype type);
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateProgramAnnotation(IntPtr annotation, string name, ParameterType type);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateProgramFromEffect(IntPtr effect, ProfileType profile, string entry, string[] args);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateProgramFromFile(IntPtr context, ProgramType type, string file, ProfileType profile, string entry, string[] args);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateSamplerState(IntPtr context, string name, ParameterType type);
+
+        //CG_API CGstateassignment CGENTRY cgCreateSamplerStateAssignment(CGparameter param, CGstate state);
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateSamplerStateAssignment(IntPtr pass, IntPtr state);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateState(IntPtr context, string name, ParameterType type);
+
+        //CG_API CGstateassignment CGENTRY cgCreateStateAssignment(CGpass pass, CGstate state);
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateStateAssignment(IntPtr pass, IntPtr state);
+
+        //CG_API CGstateassignment CGENTRY cgCreateStateAssignmentIndex(CGpass pass, CGstate state, int index);
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateStateAssignmentIndex(IntPtr pass, IntPtr state, int index);
+
+        //CG_API CGtechnique CGENTRY cgCreateTechnique(CGeffect effect, const char *name);
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateTechnique(IntPtr effect, string name);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern IntPtr cgCreateTechniqueAnnotation(IntPtr tech, string name, ParameterType type);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]
+        [SuppressUnmanagedCodeSecurity]
+        internal static extern void cgDestroyBuffer(IntPtr buffer);
+
+        [DllImport(CgNativeLibrary, CallingConvention = Convention)]