/// <summary> /// Creates a new buffer from an existing OpenGL buffer object. /// </summary> /// <typeparam name="DataType"> The type of the elements of the buffer. <typeparamref name="T"/> should match the type of the elements in the OpenGL buffer. </typeparam> /// <param name="context"> A context with enabled CL/GL sharing. </param> /// <param name="flags"> A bit-field that is used to specify usage information about the buffer. Only <see cref="ComputeMemoryFlags.ReadOnly"/>, <see cref="ComputeMemoryFlags.WriteOnly"/> and <see cref="ComputeMemoryFlags.ReadWrite"/> are allowed. </param> /// <param name="bufferId"> The OpenGL buffer object id to use for the creation of the buffer. </param> /// <returns> The created buffer. </returns> public static ComputeBuffer <DataType> CreateFromGLBuffer <DataType>(IComputeContext context, ComputeMemoryFlags flags, int bufferId) where DataType : struct { var handle = CL10.CreateFromGLBuffer(context.Handle, flags, bufferId, out ComputeErrorCode error); ComputeException.ThrowOnError(error); return(new ComputeBuffer <DataType>(handle, context, flags)); }