VertexBuffer, VertexLayout and GeometryBinding improvements

- VertexBuffer: Added constructor that takes stride instead of type
- VertexLayout: Added Refcounting to VertexLayout and ownership parameters for VertexElements
- Fixed: GeometryBinding using stride and offset from buffer instead of buffer binding
This commit is contained in:
Simon Lübeß
2021-08-05 18:32:21 +02:00
parent e04d058381
commit 5c0ee3bae0
7 changed files with 65 additions and 32 deletions
+5 -5
View File
@@ -50,8 +50,6 @@ namespace Sandbox
}
}
VertexLayout _vertexLayout ~ delete _;
GeometryBinding _geometryBinding ~ _?.ReleaseRef();
GeometryBinding _quadGeometryBinding ~ _?.ReleaseRef();
@@ -91,7 +89,7 @@ namespace Sandbox
// Create Input Layout
_vertexLayout = new VertexLayout(_context, VertexColorTexture.VertexElements, textureEffect.VertexShader);
VertexLayout vertexLayout = new VertexLayout(_context, VertexColorTexture.VertexElements, false, textureEffect.VertexShader);
textureEffect.ReleaseRef();
@@ -99,7 +97,7 @@ namespace Sandbox
{
_geometryBinding = new GeometryBinding(_context);
_geometryBinding.SetPrimitiveTopology(.TriangleList);
_geometryBinding.SetVertexLayout(_vertexLayout);
_geometryBinding.SetVertexLayout(vertexLayout);
float pO3 = Math.PI_f / 3.0f;
VertexColorTexture[?] vertices = .(
@@ -135,7 +133,7 @@ namespace Sandbox
{
_quadGeometryBinding = new GeometryBinding(_context);
_quadGeometryBinding.SetPrimitiveTopology(.TriangleList);
_quadGeometryBinding.SetVertexLayout(_vertexLayout);
_quadGeometryBinding.SetVertexLayout(vertexLayout);
VertexColorTexture[?] vertices = .(
VertexColorTexture(Vector3(-0.75f, 0.75f, 0), Color.White, .(0, 0)),
@@ -159,6 +157,8 @@ namespace Sandbox
qib.ReleaseRef();
}
vertexLayout.ReleaseRef();
// Create rasterizer state
RasterizerStateDescription rsDesc = .(.Solid, .Back, true);
_rasterizerState = new RasterizerState(_context, rsDesc);