

_ebo = new (_gl, Indices, BufferTargetARB.ElementArrayBuffer);
_vbo = new (_gl, Vertices, BufferTargetARB.ArrayBuffer);
_vao = new (_gl, _vbo, _ebo);
_vao.VertexAttributePointer(0, 2, VertexAttribPointerType.Float, 4, 0);
_vao.VertexAttributePointer(1, 2, VertexAttribPointerType.Float, 4, 2); _gl.UseProgram(_shader.Handle);
_vao.Bind();
_gl.ActiveTexture(TextureUnit.Texture0);
_gl.BindTexture(TextureTarget.Texture2D, texture.Handle);
_gl.Uniform1(_uTextureLocation, 0);
SetMatrix(_uViewLocation, camMatrix.View);
SetMatrix(_uProjectionLocation, camMatrix.Projection);
var model = Matrix4x4.Identity * Matrix4x4.CreateScale(size.X, size.Y, 1) * Matrix4x4.CreateRotationZ(DegreesToRadians(rotation)) * Matrix4x4.CreateTranslation(position.X, position.Y, 0);
SetMatrix(_uModelLocation, model);
_gl.DrawElements(PrimitiveType.Triangles, (uint) Indices.Length, DrawElementsType.UnsignedInt, null); _ebo = new (_gl, Indices, BufferTargetARB.ElementArrayBuffer);
_vbo = new (_gl, Vertices, BufferTargetARB.ArrayBuffer);
_vao = new (_gl, _vbo, _ebo);
_vao.VertexAttributePointer(0, 2, VertexAttribPointerType.Float, 0, 0); _gl.UseProgram(_shader.Handle);
_vao.Bind();
_gl.Uniform4(_uColorLocation, Vector4.One);
SetMatrix(_uViewLocation, camMatrix.View);
SetMatrix(_uProjectionLocation, camMatrix.Projection);
var model = Matrix4x4.Identity
* Matrix4x4.CreateScale(size.X, size.Y, 1)
* Matrix4x4.CreateRotationZ(DegreesToRadians(rotation))
* Matrix4x4.CreateTranslation(position.X, position.Y, 0);
SetMatrix(_uModelLocation, model);
_gl.DrawElements(PrimitiveType.LineLoop, (uint) Indices.Length, DrawElementsType.UnsignedInt, null);_* = new (...)new (...)new(...)public unsafe BufferObject(GL gl, Span<TDataType> data, BufferTargetARB bufferType)
{
_gl = gl;
_bufferType = bufferType;
_handle = _gl.GenBuffer();
Bind();
fixed (void* d = data)
{
_gl.BufferData(bufferType, (nuint) (data.Length * sizeof(TDataType)), d, BufferUsageARB.StaticDraw);
}
}public VertexArrayObject(GL gl, BufferObject<TVertexType> vbo, BufferObject<TIndexType> ebo)
{
_gl = gl;
_handle = _gl.GenVertexArray();
Bind();
vbo.Bind();
ebo.Bind();
}vao.bind()
vbo.bind()
vao.VertexAttribStuff(...)
vbo2.bind()
vao.VertexAttribStuff(...)using Serilog;
using Silk.NET.OpenGL;
namespace ProjectUnknown.Engine.Rendering;
public class BufferObject<TDataType> : IDisposable
where TDataType : unmanaged
{
private uint _handle;
private BufferTargetARB _bufferType;
private GL _gl;
public unsafe BufferObject(GL gl, Span<TDataType> data, BufferTargetARB bufferType)
{
_gl = gl;
_bufferType = bufferType;
_handle = _gl.GenBuffer();
Bind();
fixed (void* d = data)
{
_gl.BufferData(bufferType, (nuint) (data.Length * sizeof(TDataType)), d, BufferUsageARB.StaticDraw);
}
}
public void Bind()
{
_gl.BindBuffer(_bufferType, _handle);
}
public void Dispose()
{
_gl.DeleteBuffer(_handle);
}
}using Serilog;
using Silk.NET.OpenGL;
namespace ProjectUnknown.Engine.Rendering;
public class VertexArrayObject<TVertexType, TIndexType> : IDisposable
where TVertexType : unmanaged
where TIndexType : unmanaged
{
private uint _handle;
private GL _gl;
public VertexArrayObject(GL gl, BufferObject<TVertexType> vbo, BufferObject<TIndexType> ebo)
{
_gl = gl;
_handle = _gl.GenVertexArray();
Bind();
vbo.Bind();
ebo.Bind();
}
public unsafe void VertexAttributePointer(uint index, int count, VertexAttribPointerType type, uint vertexSize, int offSet)
{
_gl.VertexAttribPointer(index, count, type, false, vertexSize * (uint) sizeof(TVertexType), (void*) (offSet * sizeof(TVertexType)));
_gl.EnableVertexAttribArray(index);
}
public void Bind()
{
_gl.BindVertexArray(_handle);
}
public void Dispose()
{
_gl.DeleteVertexArray(_handle);
}
}_ebo = new (_gl, Indices, BufferTargetARB.ElementArrayBuffer);
_vbo = new (_gl, Vertices, BufferTargetARB.ArrayBuffer);
_vao = new (_gl, _vbo, _ebo);
_vao.VertexAttributePointer(0, 2, VertexAttribPointerType.Float, 0, 0);
_vao.UnBind();Window.Create(options).Run()