make new opengl source generator

This commit is contained in:
Youmu Liu
2026-08-26 18:12:08 +08:00
parent 65041ff8bc
commit 75bf7fc139
126 changed files with 8934 additions and 26139 deletions
+7 -62
View File
@@ -5,72 +5,17 @@
// SPDX-License-Identifier: MIT
// -----------------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Graphics.OpenGL;
using StgSharp.Mathematics;
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Graphics.OpenGL
{
/// <summary>
/// A collection of handle to Element BufferHandle Object in OpenglFunc. Each <see ///
/// langword="uint" /> value indexed from instance of this class this is the only handle to
/// one Element BufferHandle Object.
/// </summary>
public sealed unsafe class ElementBuffer : GlBufferObjectBase
/// <summary>A set of OpenGL element-buffer handles.</summary>
public sealed record class ElementBuffer(
GlHandle[] Handles
)
{
internal ElementBuffer(
int n,
glRender binding
)
: base(binding)
{
_bufferHandle = GL.GenBuffers(n);
}
public int Count => Handles.Length;
public sealed override void Bind(
int index
)
{
GL.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
}
public void SetValue<T>(
int index,
T[] bufferArray,
BufferUsage usage
) where T : unmanaged, INumber<T>
{
GL.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
GL.SetBufferData<T>(BufferType.ElementArrayBuffer, bufferArray, usage);
}
public void SetValue<T>(
int index,
ReadOnlySpan<T> bufferSpan,
BufferUsage usage
) where T : unmanaged, INumber<T>
{
GL.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
GL.SetBufferData<T>(BufferType.ElementArrayBuffer, bufferSpan, usage);
}
protected sealed override void Dispose(
bool disposing
)
{
if (disposing) {
GL.DeleteBuffers(_bufferHandle);
}
}
public GlHandle this[int index] => Handles[index];
}
}
}