From c21557c4ebbf0e979cf29a90d9f75ffca909d4fc Mon Sep 17 00:00:00 2001 From: "Paul C. Scharf" Date: Wed, 14 Aug 2024 20:34:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=8D=20Allow=20buffers=20to=20upload=20?= =?UTF-8?q?data=20from=20spans?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bearded.Graphics/Core/Buffer.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Bearded.Graphics/Core/Buffer.cs b/Bearded.Graphics/Core/Buffer.cs index 91aa505..083e1e8 100644 --- a/Bearded.Graphics/Core/Buffer.cs +++ b/Bearded.Graphics/Core/Buffer.cs @@ -64,6 +64,12 @@ private void bufferData(T[]? data, int count, BufferTarget target, BufferUsageHi GL.BufferData(target, itemSize * count, data, usageHint); } + public void Upload(Span data, BufferUsageHint usageHint = defaultUsageHint) + { + buffer.Count = data.Length; + GL.BufferData(target, itemSize * data.Length, ref data[0], usageHint); + } + public void Dispose() { GL.BindBuffer(target, 0);