Added GeometryBinding

This commit is contained in:
Simon Lübeß
2021-01-06 19:22:43 +01:00
parent 4a5a90c859
commit 9eb4a19df1
3 changed files with 193 additions and 9 deletions
@@ -0,0 +1,83 @@
using System;
using System.Collections;
namespace GlitchyEngine.Renderer
{
public class GeometryBinding
{
internal List<VertexBufferBinding> _vertexBuffers = new .() ~ delete _;
internal IndexBuffer _indexBuffer;
internal VertexLayout _vertexLayout;
internal uint32 _indexByteOffset;
internal uint32 _indexCount;
internal PrimitiveTopology _primitiveTopology;
public VertexBufferBinding GetVertexBuffer(uint32 slot)
{
return _vertexBuffers[slot];
}
public IndexBuffer GetIndexBuffer()
{
return _indexBuffer;
}
public VertexLayout GetVertexLayout()
{
return _vertexLayout;
}
[Inline]
public uint32 IndexByteOffset => _indexByteOffset;
[Inline]
public uint32 IndexCount => _indexCount;
[Inline]
public PrimitiveTopology PrimitiveTopology => _primitiveTopology;
public void SetVertexBufferSlot(VertexBufferBinding vertexBufferBinding, uint32 slot)
{
_vertexBuffers.Add(vertexBufferBinding);
PlatformSetVertexBuffer(vertexBufferBinding, slot);
}
protected extern void PlatformSetVertexBuffer(VertexBufferBinding vertexBuffer, uint32 slot);
public void SetVertexLayout(VertexLayout vertexLayout)
{
_vertexLayout = vertexLayout;
PlatformSetVertexLayout(vertexLayout);
}
protected extern void PlatformSetVertexLayout(VertexLayout layout);
public void SetPrimitiveTopology(PrimitiveTopology topology)
{
_primitiveTopology = topology;
PlatformSetPrimitiveTopology(topology);
}
protected extern void PlatformSetPrimitiveTopology(PrimitiveTopology topology);
public void SetIndexBuffer(IndexBuffer indexBuffer, uint32 byteOffset = 0, uint32 indexCount = (.)-1)
{
_indexBuffer = indexBuffer;
_indexByteOffset = byteOffset;
if(indexCount == (.)-1)
{
_indexCount = _indexBuffer.IndexCount - (uint32)(_indexByteOffset / _indexBuffer.Format.IndexSize);
}
else
{
_indexCount = indexCount;
}
PlatformSetIndexBuffer(indexBuffer);
}
protected extern void PlatformSetIndexBuffer(IndexBuffer indexBuffer);
}
}