mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-06 05:01:53 +00:00
47 lines
1.0 KiB
Beef
47 lines
1.0 KiB
Beef
using System;
|
|
namespace GlitchyEngine.Renderer
|
|
{
|
|
public struct VertexBufferBinding
|
|
{
|
|
public VertexBuffer Buffer;
|
|
public uint32 Stride;
|
|
public uint32 Offset;
|
|
|
|
public this(VertexBuffer buffer, uint32 stride, uint32 offset = 0)
|
|
{
|
|
Buffer = buffer;
|
|
Stride = stride;
|
|
Offset = offset;
|
|
}
|
|
}
|
|
|
|
public class VertexBuffer : Buffer
|
|
{
|
|
private VertexBufferBinding _defaultBinding;
|
|
|
|
private Type _vertexType;
|
|
|
|
public Type VertexDataType => _vertexType;
|
|
|
|
public VertexBufferBinding Binding => _defaultBinding;
|
|
|
|
public this(GraphicsContext context, Type vertexType, uint32 vertexCount, Usage usage = .Default, CPUAccessFlags cpuAccess = .None) : base(context)
|
|
{
|
|
_vertexType = vertexType;
|
|
|
|
_description = .(){
|
|
Size = ((uint32)_vertexType.Size * vertexCount),
|
|
Usage = usage,
|
|
CPUAccess = cpuAccess,
|
|
BindFlags = .Vertex,
|
|
MiscFlags = .None
|
|
};
|
|
|
|
_defaultBinding = .(this, (.)_vertexType.Size, 0);
|
|
}
|
|
|
|
[Inline]
|
|
public static implicit operator VertexBufferBinding(Self buffer) => buffer._defaultBinding;
|
|
}
|
|
}
|