From 523da5536bf8938755f4e20db2830d1988ba4059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Sat, 2 Jan 2021 16:32:08 +0100 Subject: [PATCH] (Breaking) Made VertexLayout initialization sexy --- GlitchyEngine/src/Application.bf | 6 +++--- .../src/Platform/DX11/Renderer/Dx11VertexLayout.bf | 6 +++--- GlitchyEngine/src/Renderer/VertexLayout.bf | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/GlitchyEngine/src/Application.bf b/GlitchyEngine/src/Application.bf index 6e81a1e..7103846 100644 --- a/GlitchyEngine/src/Application.bf +++ b/GlitchyEngine/src/Application.bf @@ -91,9 +91,9 @@ namespace GlitchyEngine // Create Input Layout _vertexLayout = new VertexLayout(_window.Context, new .( - VertexElement("POSITION", 0, .R32G32B32_Float, 0), - VertexElement("COLOR", 0, .R8G8B8A8_UNorm, 0) - ), _vertexShader.[Friend]nativeCode); + VertexElement(.R32G32B32_Float, "POSITION"), + VertexElement(.R8G8B8A8_UNorm, "COLOR"), + ), _vertexShader); // // Load pixel shader diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11VertexLayout.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11VertexLayout.bf index e6c1723..91f587f 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11VertexLayout.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11VertexLayout.bf @@ -11,11 +11,11 @@ namespace GlitchyEngine.Renderer { internal ID3D11InputLayout* nativeLayout ~ _?.Release(); - public ID3DBlob* nativeShaderCode; + public ID3DBlob* nativeShaderCode ~ _?.Release(); - public this(GraphicsContext context, VertexElement[] ownElements, ID3DBlob* nativeShaderCode) + public this(GraphicsContext context, VertexElement[] ownElements, VertexShader vertexShader) { - this.nativeShaderCode = nativeShaderCode; + nativeShaderCode = vertexShader.nativeCode..AddRef(); _context = context; _elements = ownElements; diff --git a/GlitchyEngine/src/Renderer/VertexLayout.bf b/GlitchyEngine/src/Renderer/VertexLayout.bf index 8531f9b..e58c49b 100644 --- a/GlitchyEngine/src/Renderer/VertexLayout.bf +++ b/GlitchyEngine/src/Renderer/VertexLayout.bf @@ -56,11 +56,11 @@ namespace GlitchyEngine.Renderer public this() => this = default; - public this(String semanticName, uint32 semanticIndex, Format format, uint32 inputSlot, uint32 offset = (.)-1, InputClassification slotClass = .PerVertexData, uint32 instanceStepRate = 0) + public this(Format format, String semanticName, uint32 semanticIndex = 0, uint32 inputSlot = 0, uint32 offset = (.)-1, InputClassification slotClass = .PerVertexData, uint32 instanceStepRate = 0) { + Format = format; SemanticName = semanticName; SemanticIndex = semanticIndex; - Format = format; InputSlot = inputSlot; AlignedByteOffset = offset; InputSlotClass = slotClass; @@ -85,7 +85,7 @@ namespace GlitchyEngine.Renderer // Todo: DirectX needs shader! /// Takes ownership of ownElements! - public this(GraphicsContext context, VertexElement[] ownElements) + public this(GraphicsContext context, VertexElement[] ownElements, VertexShader vertexShader) { _context = context; _elements = ownElements;