Unbind vao, vbo and ibo after data is set

This commit is contained in:
miku-666
2024-02-07 13:01:19 +01:00
parent 4bc265968f
commit 09a508a0ec
3 changed files with 6 additions and 4 deletions

View File

@@ -35,6 +35,7 @@ namespace PckStudio.Rendering
_id = GL.GenBuffer();
Bind();
GL.BufferData(BufferTarget.ElementArrayBuffer, _indecies.Count * sizeof(int), _indecies.ToArray(), BufferUsageHint.StaticDraw);
Unbind();
}
public int GetCount() => _indecies.Count;

View File

@@ -30,6 +30,7 @@ namespace PckStudio.Rendering
GL.VertexAttribPointer(i, element.Count, element.Type, element.Normalize, layout.GetStride(), offset);
offset += element.Count * VertexBufferElement.GetStrideSize(element.Type);
}
Unbind();
}
public void Bind()

View File

@@ -20,12 +20,13 @@ namespace PckStudio.Rendering
public VertexBuffer(T[] data, int size)
{
_id = GL.GenBuffer();
Bind();
GL.BufferData(BufferTarget.ArrayBuffer, size, data, BufferUsageHint.StaticDraw);
#if DEBUG
__data = data;
#endif
_id = GL.GenBuffer();
Bind();
GL.BufferData(BufferTarget.ArrayBuffer, size, data, BufferUsageHint.StaticDraw);
Unbind();
}
public void Bind()
@@ -33,7 +34,6 @@ namespace PckStudio.Rendering
GL.BindBuffer(BufferTarget.ArrayBuffer, _id);
}
[Conditional("DEBUG")]
public void Unbind()
{
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);