/// <summary>
        /// 获取非托管数组的最后一个元素的地址再向后一个单位的地址。
        /// </summary>
        /// <param name="array"></param>
        /// <returns></returns>
        public static unsafe void *TailAddress(this UnmanagedArrayBase array)
        {
            void *tail = (array.Header + array.ByteLength).ToPointer();

            return(tail);
        }
        /// <summary>
        /// 获取非托管数组的最后一个元素的地址。
        /// </summary>
        /// <param name="array"></param>
        /// <returns></returns>
        public static unsafe void *LastElement(this UnmanagedArrayBase array)
        {
            void *last = (array.Header + (array.ByteLength - array.ByteLength / array.Length)).ToPointer();

            return(last);
        }
예제 #3
0
 //[MethodImpl(MethodImplOptions.Synchronized)]//这造成死锁,不知道是为什么
 private static void Add(UnmanagedArrayBase array)
 {
     allocatedArrays.Add(array);
 }
        ///// <summary>
        ///// 错误	1	无法获取托管类型(“T”)的地址和大小,或无法声明指向它的指针	C:\Users\威\Documents\GitHub\CSharpGL\Utilities\UnmanagedArrayHelper.cs	16	33	Utilities
        ///// </summary>
        ///// <typeparam name="T"></typeparam>
        ///// <param name="array"></param>
        ///// <returns></returns>
        //public static unsafe T* FirstElement<T>(this UnmanagedArray<T> array) where T : struct
        //{
        //    var header = (void*)array.Header;
        //    return (T*)header;
        //}

        /// <summary>
        /// 获取非托管数组的第一个元素的地址。
        /// </summary>
        /// <param name="array"></param>
        /// <returns></returns>
        public static unsafe void *FirstElement(this UnmanagedArrayBase array)
        {
            void *header = array.Header.ToPointer();

            return(header);
        }
예제 #5
0
 /// <summary>
 /// 把此非托管数组复制到目标内存地址上。
 /// </summary>
 /// <param name="source"></param>
 /// <param name="destination">例如用glMapBuffer()得到的地址。</param>
 public static void CopyTo(this UnmanagedArrayBase source, IntPtr destination)
 {
     CopyMemory(destination, source.Header, (uint)source.ByteLength);
 }