public virtual void ReplaceBufferData(OpenGL gl, OGLBufferDataTarget target, int offset, int size, IntPtr newData, bool bind = false, OGLBindBufferTarget bindTarget = OGLBindBufferTarget.ArrayBuffer) { if (bind) { BindBuffer(gl, bindTarget); } gl.BufferSubData((uint)target, offset, size, newData); }
/// <summary> /// Calls the glBufferData(...). The size will be used as value for Size property. /// </summary> /// <param name="gl">The gl.</param> /// <param name="target">The buffer data target.</param> /// <param name="size">The size of the data buffer.</param> /// <param name="data">The pointer to the data in memory.</param> /// <param name="usage">The usage.</param> public virtual void SetBufferData(OpenGL gl, OGLBufferDataTarget target, int size, IntPtr data, OGLModelUsage usage, int stride, OGLType bufferDataType, bool bind = false, OGLBindBufferTarget bindTarget = OGLBindBufferTarget.ArrayBuffer) { Size = size / stride; Stride = stride; if (bind) { BindBuffer(gl, bindTarget); } gl.BufferData((uint)target, size, data, (uint)usage); }
public virtual void ReplaceBufferData(OpenGL gl, OGLBufferDataTarget target, int offset, uint[] newData, bool bind = false, OGLBindBufferTarget bindTarget = OGLBindBufferTarget.ArrayBuffer) { IntPtr newDataPtr; // Unsafe code. unsafe { // Fix the pointer to the array. fixed(uint *pArray = newData) { // pArray now has the pointer to the array. You can get an IntPtr by casting to void, and passing that in. newDataPtr = new IntPtr((void *)pArray); } } ReplaceBufferData(gl, target, offset, newData.Length, newDataPtr, bind, bindTarget); }
/// <summary> /// Calls glBindBuffer. /// </summary> /// <param name="gl"></param> public virtual void BindBuffer(OpenGL gl, OGLBindBufferTarget target, VertexAttribPointer pointer = null) { gl.BindBuffer((uint)target, BufferId.Value); VertexAttribPointer pointerToUse = null; if (pointer != null) { pointerToUse = pointer; } else if (VertexAttribPointer != null) { pointerToUse = VertexAttribPointer; } if (pointerToUse != null) { pointerToUse.Invoke(gl); gl.EnableVertexAttribArray(pointerToUse.Index); } }
/// <summary> /// Calls glBindBuffer. /// </summary> /// <param name="gl"></param> public virtual void BindBuffer(OpenGL gl, OGLBindBufferTarget target, VertexAttribPointer pointer = null) { gl.BindBuffer((uint)target, BufferId.Value); VertexAttribPointer pointerToUse = null; if (pointer != null) pointerToUse = pointer; else if (VertexAttribPointer != null) pointerToUse = VertexAttribPointer; if (pointerToUse != null) { pointerToUse.Invoke(gl); gl.EnableVertexAttribArray(pointerToUse.Index); } }
/// <summary> /// Calls the glBufferData(...). The size will be used as value for Size property. /// </summary> /// <param name="gl">The gl.</param> /// <param name="target">The buffer data target.</param> /// <param name="size">The size of the data buffer.</param> /// <param name="data">The pointer to the data in memory.</param> /// <param name="usage">The usage.</param> public virtual void SetBufferData(OpenGL gl, OGLBufferDataTarget target, int size, IntPtr data, OGLModelUsage usage, int stride, OGLType bufferDataType, bool bind = false, OGLBindBufferTarget bindTarget = OGLBindBufferTarget.ArrayBuffer) { Size = size / stride; Stride = stride; if(bind) BindBuffer(gl, bindTarget); gl.BufferData((uint)target, size, data, (uint)usage); }
public virtual void ReplaceBufferData(OpenGL gl, OGLBufferDataTarget target, int offset, int size, IntPtr newData, bool bind = false, OGLBindBufferTarget bindTarget = OGLBindBufferTarget.ArrayBuffer) { if (bind) BindBuffer(gl, bindTarget); gl.BufferSubData((uint)target, offset, size, newData); }
public virtual void ReplaceBufferData(OpenGL gl, OGLBufferDataTarget target, int offset, uint[] newData, bool bind = false, OGLBindBufferTarget bindTarget = OGLBindBufferTarget.ArrayBuffer) { IntPtr newDataPtr; // Unsafe code. unsafe { // Fix the pointer to the array. fixed (uint* pArray = newData) { // pArray now has the pointer to the array. You can get an IntPtr by casting to void, and passing that in. newDataPtr = new IntPtr((void*)pArray); } } ReplaceBufferData(gl, target, offset, newData.Length, newDataPtr, bind, bindTarget); }