Similar to array in int array[Length];
int array[Length];
/// <summary> /// Fill a buffer object's data store with a fixed value. /// </summary> /// <param name="internalFormat">The sized internal format with which the data will be stored in the buffer object.</param> /// <param name="format">Specifies the format of the pixel data. For transfers of depth, stencil, or depth/stencil data, you must use GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, or GL_DEPTH_STENCIL, where appropriate. For transfers of normalized integer or floating-point color image data, you must use one of the following: GL_RED, GL_GREEN, GL_BLUE, GL_RG, GL_RGB, GL_BGR, GL_RGBA, and GL_BGRA. For transfers of non-normalized integer data, you must use one of the following: GL_RED_INTEGER, GL_GREEN_INTEGER, GL_BLUE_INTEGER, GL_RG_INTEGER, GL_RGB_INTEGER, GL_BGR_INTEGER, GL_RGBA_INTEGER, and GL_BGRA_INTEGER.</param> /// <param name="type">Specifies the data type of the pixel data. The following symbolic values are accepted: GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, GL_FLOAT, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2, and GL_UNSIGNED_INT_2_10_10_10_REV.</param> /// <param name="data">Specifies a pointer to a single pixel of data to upload. This parameter may not be null.</param> /// <param name="autoBind">Automatically call glBindBuffer() inside this method.</param> /// <returns></returns> public bool ClearBufferData(uint internalFormat, uint format, uint type, UnmanagedArrayBase data, bool autoBind = true) { if (data == null || data.Header == IntPtr.Zero) { throw new ArgumentNullException("data"); } return(ClearBufferData(internalFormat, format, type, data.Header, autoBind)); }
/// <summary> /// 获取顶点属性Buffer。描述顶点的位置或颜色或UV等各种属性。 /// <para>每个<see cref="VertexBuffer"/>仅描述其中一个属性。</para> /// <para>Vertex Buffer Object that describes vertex' property(position, color, uv coordinate, etc.).</para> /// <para>Each <see cref="VertexBuffer"/> describes only 1 property.</para> /// </summary> /// <param name="array"></param> /// <param name="config">This <paramref name="config"/> decides parameters' values in glVertexAttribPointer(attributeLocation, size, type, false, 0, IntPtr.Zero);</param> /// <param name="varNameInVertexShader">此顶点属性VBO对应于vertex shader中的哪个in变量?<para>Mapping variable's name in vertex shader.</para></param> /// <param name="usage"></param> /// <param name="instancedDivisor">0: not instanced. 1: instanced divisor is 1.</param> /// <param name="patchVertexes">How many vertexes makes a patch? No patch if <paramref name="patchVertexes"/> is 0.</param> /// <returns></returns> public static VertexBuffer GenVertexBuffer <T>(this T[] array, VBOConfig config, string varNameInVertexShader, BufferUsage usage, uint instancedDivisor = 0, int patchVertexes = 0) where T : struct { GCHandle pinned = GCHandle.Alloc(array, GCHandleType.Pinned); IntPtr header = Marshal.UnsafeAddrOfPinnedArrayElement(array, 0); UnmanagedArrayBase unmanagedArray = UnmanagedArray <T> .FromHandle(header, array.Length);// It's not neecessary to call Dispose() for this unmanaged array. VertexBuffer buffer = GenVertexBuffer(unmanagedArray, config, varNameInVertexShader, usage, instancedDivisor, patchVertexes); pinned.Free(); return(buffer); }
/// <summary> /// Generates an independent buffer. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="array"></param> /// <param name="target"></param> /// <param name="usage"></param> /// <returns></returns> private static Buffer GenIndependentBuffer <T>(this T[] array, IndependentBufferTarget target, BufferUsage usage) where T : struct { GCHandle pinned = GCHandle.Alloc(array, GCHandleType.Pinned); IntPtr header = Marshal.UnsafeAddrOfPinnedArrayElement(array, 0); UnmanagedArrayBase unmanagedArray = UnmanagedArray <T> .FromHandle(header, array.Length);// It's not neecessary to call Dispose() for this unmanaged array. Buffer buffer = GenIndependentBuffer(unmanagedArray, target, usage); pinned.Free(); return(buffer); }
/// <summary> /// 获取此VBO的内存首地址。用于快速读写。 /// </summary> /// <returns></returns> public unsafe void *FirstElement() { UnmanagedArrayBase array = this.array; if (array == null) { return((void *)0); } else { return(array.FirstElement()); } }
/// <summary> /// Fill all or part of buffer object's data store with a fixed value. /// </summary> /// <param name="offset">The offset, in basic machine units into the buffer object's data store at which to start filling.</param> /// <param name="size">The size, in basic machine units of the range of the data store to fill.</param> /// <param name="data">Specifies a pointer to a single pixel of data to upload. This parameter may not be null.</param> /// <param name="autoBind">Automatically call glBindBuffer() inside this method.</param> /// <returns></returns> public bool ClearBufferSubData(int offset, uint size, vec3 data, bool autoBind = true) { var array = new vec3[] { data }; GCHandle pin = GCHandle.Alloc(array, GCHandleType.Pinned); IntPtr header = Marshal.UnsafeAddrOfPinnedArrayElement(array, 0); UnmanagedArrayBase unmanagedArray = UnmanagedArray <vec3> .FromHandle(header, 1); bool result = ClearBufferSubData(OpenGL.GL_RGB32F, new IntPtr(offset), size, OpenGL.GL_RGB, OpenGL.GL_FLOAT, unmanagedArray, autoBind); pin.Free(); return(result); }
///// <summary> ///// Generates an atomic counter buffer. ///// </summary> ///// <param name="array"></param> ///// <param name="usage"></param> ///// <returns></returns> //public static AtomicCounterBuffer GenAtomicCounterBuffer(this UnmanagedArrayBase array, BufferUsage usage) //{ // return GenIndependentBuffer(array, IndependentBufferTarget.AtomicCounterBuffer, usage) as AtomicCounterBuffer; //} ///// <summary> ///// Generates a pixel pack buffer. ///// </summary> ///// <param name="array"></param> ///// <param name="usage"></param> ///// <returns></returns> //public static PixelPackBuffer GenPixelPackBuffer(this UnmanagedArrayBase array, BufferUsage usage) //{ // return GenIndependentBuffer(array, IndependentBufferTarget.PixelPackBuffer, usage) as PixelPackBuffer; //} ///// <summary> ///// Generates a pixel unpack buffer. ///// </summary> ///// <param name="array"></param> ///// <param name="usage"></param> ///// <returns></returns> //public static PixelUnpackBuffer GenPixelUnpackBuffer(this UnmanagedArrayBase array, BufferUsage usage) //{ // return GenIndependentBuffer(array, IndependentBufferTarget.PixelUnpackBuffer, usage) as PixelUnpackBuffer; //} ///// <summary> ///// Generates a shader storage buffer. ///// </summary> ///// <param name="array"></param> ///// <param name="usage"></param> ///// <returns></returns> //public static ShaderStorageBuffer GenShaderStorageBuffer(this UnmanagedArrayBase array, BufferUsage usage) //{ // return GenIndependentBuffer(array, IndependentBufferTarget.ShaderStorageBuffer, usage) as ShaderStorageBuffer; //} ///// <summary> ///// Generates a texture buffer. ///// </summary> ///// <param name="array"></param> ///// <param name="usage"></param> ///// <returns></returns> //public static TextureBuffer GenTextureBuffer(this UnmanagedArrayBase array, BufferUsage usage) //{ // return GenIndependentBuffer(array, IndependentBufferTarget.TextureBuffer, usage) as TextureBuffer; //} ///// <summary> ///// Generates an uniform buffer. ///// </summary> ///// <param name="array"></param> ///// <param name="usage"></param> ///// <returns></returns> //public static UniformBuffer GenUniformBuffer(this UnmanagedArrayBase array, BufferUsage usage) //{ // return GenIndependentBuffer(array, IndependentBufferTarget.UniformBuffer, usage) as UniformBuffer; //} /// <summary> /// Generates an independent buffer. /// </summary> /// <param name="array"></param> /// <param name="bufferTarget"></param> /// <param name="usage"></param> /// <returns></returns> private static GLBuffer GenIndependentBuffer(this UnmanagedArrayBase array, IndependentBufferTarget bufferTarget, BufferUsage usage) { if (glGenBuffers == null) { InitFunctions(); } uint[] buffers = new uint[1]; glGenBuffers(1, buffers); var target = (uint)bufferTarget; glBindBuffer(target, buffers[0]); glBufferData(target, array.ByteLength, array.Header, (uint)usage); glBindBuffer(target, 0); GLBuffer buffer = null; switch (bufferTarget) { case IndependentBufferTarget.AtomicCounterBuffer: buffer = new AtomicCounterBuffer(buffers[0], array.Length, array.ByteLength); break; case IndependentBufferTarget.PixelPackBuffer: buffer = new PixelPackBuffer(buffers[0], array.Length, array.ByteLength); break; case IndependentBufferTarget.PixelUnpackBuffer: buffer = new PixelUnpackBuffer(buffers[0], array.Length, array.ByteLength); break; case IndependentBufferTarget.ShaderStorageBuffer: buffer = new ShaderStorageBuffer(buffers[0], array.Length, array.ByteLength); break; case IndependentBufferTarget.TextureBuffer: buffer = new TextureBuffer(buffers[0], array.Length, array.ByteLength); break; case IndependentBufferTarget.UniformBuffer: buffer = new UniformBuffer(buffers[0], array.Length, array.ByteLength); break; default: throw new NotImplementedException(); } return(buffer); }
///// <summary> ///// Generates an atomic counter buffer. ///// </summary> ///// <param name="array"></param> ///// <param name="usage"></param> ///// <returns></returns> //public static AtomicCounterBuffer GenAtomicCounterBuffer(this UnmanagedArrayBase array, BufferUsage usage) //{ // return GenIndependentBuffer(array, IndependentBufferTarget.AtomicCounterBuffer, usage) as AtomicCounterBuffer; //} ///// <summary> ///// Generates a pixel pack buffer. ///// </summary> ///// <param name="array"></param> ///// <param name="usage"></param> ///// <returns></returns> //public static PixelPackBuffer GenPixelPackBuffer(this UnmanagedArrayBase array, BufferUsage usage) //{ // return GenIndependentBuffer(array, IndependentBufferTarget.PixelPackBuffer, usage) as PixelPackBuffer; //} ///// <summary> ///// Generates a pixel unpack buffer. ///// </summary> ///// <param name="array"></param> ///// <param name="usage"></param> ///// <returns></returns> //public static PixelUnpackBuffer GenPixelUnpackBuffer(this UnmanagedArrayBase array, BufferUsage usage) //{ // return GenIndependentBuffer(array, IndependentBufferTarget.PixelUnpackBuffer, usage) as PixelUnpackBuffer; //} ///// <summary> ///// Generates a shader storage buffer. ///// </summary> ///// <param name="array"></param> ///// <param name="usage"></param> ///// <returns></returns> //public static ShaderStorageBuffer GenShaderStorageBuffer(this UnmanagedArrayBase array, BufferUsage usage) //{ // return GenIndependentBuffer(array, IndependentBufferTarget.ShaderStorageBuffer, usage) as ShaderStorageBuffer; //} ///// <summary> ///// Generates a texture buffer. ///// </summary> ///// <param name="array"></param> ///// <param name="usage"></param> ///// <returns></returns> //public static TextureBuffer GenTextureBuffer(this UnmanagedArrayBase array, BufferUsage usage) //{ // return GenIndependentBuffer(array, IndependentBufferTarget.TextureBuffer, usage) as TextureBuffer; //} ///// <summary> ///// Generates an uniform buffer. ///// </summary> ///// <param name="array"></param> ///// <param name="usage"></param> ///// <returns></returns> //public static UniformBuffer GenUniformBuffer(this UnmanagedArrayBase array, BufferUsage usage) //{ // return GenIndependentBuffer(array, IndependentBufferTarget.UniformBuffer, usage) as UniformBuffer; //} /// <summary> /// Generates an independent buffer. /// </summary> /// <param name="array"></param> /// <param name="bufferTarget"></param> /// <param name="usage"></param> /// <returns></returns> private static GLBuffer GenIndependentBuffer(this UnmanagedArrayBase array, IndependentBufferTarget bufferTarget, BufferUsage usage) { uint[] ids = new uint[1]; { glGenBuffers(1, ids); var target = (uint)bufferTarget; glBindBuffer(target, ids[0]); glBufferData(target, array.ByteLength, array.Header, (uint)usage); glBindBuffer(target, 0); } GLBuffer buffer = null; switch (bufferTarget) { case IndependentBufferTarget.AtomicCounterBuffer: buffer = new AtomicCounterBuffer(ids[0], array.Length, array.ByteLength); break; case IndependentBufferTarget.PixelPackBuffer: buffer = new PixelPackBuffer(ids[0], array.Length, array.ByteLength); break; case IndependentBufferTarget.PixelUnpackBuffer: buffer = new PixelUnpackBuffer(ids[0], array.Length, array.ByteLength); break; case IndependentBufferTarget.ShaderStorageBuffer: buffer = new ShaderStorageBuffer(ids[0], array.Length, array.ByteLength); break; case IndependentBufferTarget.TextureBuffer: buffer = new TextureBuffer(ids[0], array.Length, array.ByteLength); break; case IndependentBufferTarget.UniformBuffer: buffer = new UniformBuffer(ids[0], array.Length, array.ByteLength); break; case IndependentBufferTarget.TransformFeedbackBuffer: buffer = new TransformFeedbackBuffer(ids[0], array.Length, array.ByteLength); break; default: throw new NotDealWithNewEnumItemException(typeof(IndependentBufferTarget)); } return(buffer); }
/// <summary> /// 生成顶点属性Buffer。描述顶点的位置或颜色或UV等各种属性。 /// <para>每个<see cref="VertexBuffer"/>仅描述其中一个属性。</para> /// <para>Vertex Buffer Object that describes vertex' property(position, color, uv coordinate, etc.).</para> /// <para>Each <see cref="VertexBuffer"/> describes only 1 property.</para> /// </summary> /// <param name="array"></param> /// <param name="config">This <paramref name="config"/> decides parameters' values in glVertexAttribPointer(attributeLocation, size, type, false, 0, IntPtr.Zero);</param> /// <param name="varNameInVertexShader">此顶点属性VBO对应于vertex shader中的哪个in变量?<para>Mapping variable's name in vertex shader.</para></param> /// <param name="usage"></param> /// <param name="instancedDivisor">0: not instanced. 1: instanced divisor is 1.</param> /// <param name="patchVertexes">How many vertexes makes a patch? No patch if <paramref name="patchVertexes"/> is 0.</param> /// <returns></returns> public static VertexBuffer GenVertexBuffer(this UnmanagedArrayBase array, VBOConfig config, string varNameInVertexShader, BufferUsage usage, uint instancedDivisor = 0, int patchVertexes = 0) { uint[] buffers = new uint[1]; glGenBuffers(1, buffers); const uint target = OpenGL.GL_ARRAY_BUFFER; glBindBuffer(target, buffers[0]); glBufferData(target, array.ByteLength, array.Header, (uint)usage); glBindBuffer(target, 0); var buffer = new VertexBuffer( buffers[0], config, array.Length, array.ByteLength, instancedDivisor, patchVertexes); return(buffer); }
/// <summary> /// 生成一个用于存储索引的IBO。索引指定了<see cref="VertexBuffer"/>里各个顶点的渲染顺序。 /// Generates a Index Buffer Object storing vertexes' indexes, which indicate the rendering order of each vertex. /// </summary> /// <param name="array"></param> /// <param name="type"></param> /// <param name="usage"></param> /// <returns></returns> public static IndexBuffer GenIndexBuffer(this UnmanagedArrayBase array, IndexBufferElementType type, BufferUsage usage) { var ids = new uint[1]; { glGenBuffers(1, ids); const uint target = GL.GL_ELEMENT_ARRAY_BUFFER; glBindBuffer(target, ids[0]); glBufferData(target, array.ByteLength, array.Header, (uint)usage); glBindBuffer(target, 0); } var buffer = new IndexBuffer(ids[0], type, array.ByteLength); return(buffer); }
/// <summary> /// 生成一个用于存储索引的VBO。索引指定了<see cref="VertexBuffer"/>里各个顶点的渲染顺序。 /// Generates a Vertex Buffer Object storing vertexes' indexes, which indicate the rendering order of each vertex. /// </summary> /// <param name="array"></param> /// <param name="mode">用哪种方式渲染各个顶点?(OpenGL.GL_TRIANGLES etc.)</param> /// <param name="usage"></param> /// <param name="primCount">primCount in instanced rendering.</param> /// <returns></returns> private static OneIndexBuffer GenIndexBuffer <T>(this T[] array, DrawMode mode, BufferUsage usage, int primCount = 1) where T : struct { IndexBufferElementType elementType; if (typeof(T) == typeof(uint)) { elementType = IndexBufferElementType.UInt; } else if (typeof(T) == typeof(ushort)) { elementType = IndexBufferElementType.UShort; } else if (typeof(T) == typeof(byte)) { elementType = IndexBufferElementType.UByte; } else { throw new ArgumentException(string.Format("Only uint/ushort/byte are allowed!")); } if (glGenBuffers == null) { InitFunctions(); } GCHandle pinned = GCHandle.Alloc(array, GCHandleType.Pinned); IntPtr header = Marshal.UnsafeAddrOfPinnedArrayElement(array, 0); UnmanagedArrayBase unmanagedArray = UnmanagedArray <T> .FromHandle(header, array.Length);// It's not neecessary to call Dispose() for this unmanaged array. var buffers = new uint[1]; { glGenBuffers(1, buffers); const uint target = OpenGL.GL_ELEMENT_ARRAY_BUFFER; glBindBuffer(target, buffers[0]); glBufferData(target, unmanagedArray.ByteLength, unmanagedArray.Header, (uint)usage); glBindBuffer(target, 0); } pinned.Free(); var buffer = new OneIndexBuffer(buffers[0], mode, elementType, unmanagedArray.Length, unmanagedArray.ByteLength, primCount); return(buffer); }
/// <summary> /// 生成顶点属性Buffer。描述顶点的位置或颜色或UV等各种属性。 /// <para>每个<see cref="VertexBuffer"/>仅描述其中一个属性。</para> /// <para>Vertex Buffer Object that describes vertex' property(position, color, uv coordinate, etc.).</para> /// <para>Each <see cref="VertexBuffer"/> describes only 1 property.</para> /// </summary> /// <param name="array"></param> /// <param name="config">This <paramref name="config"/> decides parameters' values in glVertexAttribPointer(attributeLocation, size, type, false, 0, IntPtr.Zero);</param> /// <param name="usage"></param> /// <param name="instancedDivisor">0: not instanced. 1: instanced divisor is 1.</param> /// <param name="patchVertexes">How many vertexes makes a patch? No patch if <paramref name="patchVertexes"/> is 0.</param> /// <returns></returns> public static VertexBuffer GenVertexBuffer(this UnmanagedArrayBase array, VBOConfig config, BufferUsage usage, uint instancedDivisor = 0, int patchVertexes = 0) { var ids = new uint[1]; { glGenBuffers(1, ids); const uint target = GL.GL_ARRAY_BUFFER; glBindBuffer(target, ids[0]); glBufferData(target, array.ByteLength, array.Header, (uint)usage); glBindBuffer(target, 0); } var buffer = new VertexBuffer( ids[0], config, array.Length, array.ByteLength, instancedDivisor, patchVertexes); return(buffer); }
private void Dispose(bool disposing) { if (this.disposedValue == false) { if (disposing) { // Dispose managed resources. } // Dispose unmanaged resources. UnmanagedArrayBase array = this.array; this.array = null; if (array != null) { array.Dispose(); } } this.disposedValue = true; }
/// <summary> /// 设置当前VBO的数据。 /// </summary> /// <param name="target"></param> /// <param name="data"></param> /// <param name="usage"></param> public static void BufferData(BufferTarget target, UnmanagedArrayBase data, BufferUsage usage) { GetDelegateFor<glBufferData>()((uint)target, data.ByteLength, data.Header, (uint)usage); }
/// <summary> /// Return a texture image. /// </summary> /// <param name="target">Specifies which texture is to be obtained. OpenGL.TEXTURE_1D and OpenGL.TEXTURE_2D are accepted.</param> /// <param name="level">Specifies the level-of-detail number of the desired image. Level 0 is the base image level. Level n is the nth mipmap reduction image.</param> /// <param name="format">Specifies a pixel format for the returned data.</param> /// <param name="type">Specifies a pixel type for the returned data.</param> /// <param name="pixels">Returns the texture image. Should be a pointer to an array of the type specified by type.</param> public static void GetTexImage(GetTexImageTargets target, int level, GetTexImageFormats format, GetTexImageTypes type, UnmanagedArrayBase pixels) { GL.GetTexImage((uint)target, level, (uint)format, (uint)type, pixels.Header); }
/// <summary> /// 生成顶点属性Buffer。描述顶点的位置或颜色或UV等各种属性。 /// <para>每个<see cref="VertexBuffer"/>仅描述其中一个属性。</para> /// <para>Vertex Buffer Object that describes vertex' property(position, color, uv coordinate, etc.).</para> /// <para>Each <see cref="VertexBuffer"/> describes only 1 property.</para> /// </summary> /// <param name="array"></param> /// <param name="config">This <paramref name="config"/> decides parameters' values in glVertexAttribPointer(attributeLocation, size, type, false, 0, IntPtr.Zero);</param> /// <param name="varNameInVertexShader">此顶点属性VBO对应于vertex shader中的哪个in变量?<para>Mapping variable's name in vertex shader.</para></param> /// <param name="usage"></param> /// <param name="instancedDivisor">0: not instanced. 1: instanced divisor is 1.</param> /// <param name="patchVertexes">How many vertexes makes a patch? No patch if <paramref name="patchVertexes"/> is 0.</param> /// <returns></returns> public static VertexBuffer GenVertexBuffer(this UnmanagedArrayBase array, VBOConfig config, string varNameInVertexShader, BufferUsage usage, uint instancedDivisor = 0, int patchVertexes = 0) { return(GenVertexBuffer(array.Header, array.Length, array.ByteLength, config, varNameInVertexShader, usage, instancedDivisor, patchVertexes)); }
/// <summary> /// 设置当前VBO的数据。 /// </summary> /// <param name="target"></param> /// <param name="data"></param> /// <param name="usage"></param> public static void BufferData(BufferTarget target, UnmanagedArrayBase data, BufferUsage usage) { GetDelegateFor <glBufferData>()((uint)target, data.ByteLength, data.Header, (uint)usage); }
/// <summary> /// Fill a buffer object's data store with a fixed value. /// </summary> /// <param name="internalFormat">The sized internal format with which the data will be stored in the buffer object.</param> /// <param name="format">Specifies the format of the pixel data. For transfers of depth, stencil, or depth/stencil data, you must use GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, or GL_DEPTH_STENCIL, where appropriate. For transfers of normalized integer or floating-point color image data, you must use one of the following: GL_RED, GL_GREEN, GL_BLUE, GL_RG, GL_RGB, GL_BGR, GL_RGBA, and GL_BGRA. For transfers of non-normalized integer data, you must use one of the following: GL_RED_INTEGER, GL_GREEN_INTEGER, GL_BLUE_INTEGER, GL_RG_INTEGER, GL_RGB_INTEGER, GL_BGR_INTEGER, GL_RGBA_INTEGER, and GL_BGRA_INTEGER.</param> /// <param name="type">Specifies the data type of the pixel data. The following symbolic values are accepted: GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, GL_FLOAT, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2, and GL_UNSIGNED_INT_2_10_10_10_REV.</param> /// <param name="data">Specifies a pointer to a single pixel of data to upload. This parameter may not be null.</param> /// <param name="autoBind">Automatically call glBindBuffer() inside this method.</param> /// <returns></returns> public bool ClearBufferData(uint internalFormat, uint format, uint type, UnmanagedArrayBase data, bool autoBind = true) { if (data == null || data.Header == IntPtr.Zero) { throw new ArgumentNullException("data"); } return ClearBufferData(internalFormat, format, type, data.Header, autoBind); }
/// <summary> /// 申请指定长度的非托管数组。 /// </summary> /// <param name="elementCount">数组元素的数目。</param> public void Alloc(int elementCount) { this.array = CreateElements(elementCount); }
/// <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); }