Added Buffers to Shaders

This commit is contained in:
Simon Lübeß
2020-12-30 14:47:29 +01:00
parent f3c5ac3d60
commit 9a010f7c4a
8 changed files with 183 additions and 13 deletions
+5 -5
View File
@@ -87,7 +87,7 @@ namespace GlitchyEngine
private void MakeTestTriangle()
{
_vertexShader = Shader.FromFile!<VertexShader>(_window.Context, "content\\basicShader.hlsl", "VS");
// Create Input Layout
_vertexLayout = new VertexLayout(_window.Context, new .(
@@ -100,12 +100,15 @@ namespace GlitchyEngine
//
_pixelShader = Shader.FromFile!<PixelShader>(_window.Context, "content\\basicShader.hlsl", "PS");
_pixelShader.[Friend]_buffers = new .[1];
//Todo: _pixelShader.[Friend]_buffers = new .[1];
_cBuffer = new Buffer<ColorRGBA>(_window.Context, .(0, .Constant, .Immutable, .None));
_cBuffer.Data = .White;
_cBuffer.Update();
_pixelShader.Buffers.ReplaceBuffer("Constants", _cBuffer);
float pO3 = Math.PI_f / 3.0f;
VertexColor[?] vertices = .(
VertexColor(.Zero, Color(255,255,255)),
@@ -171,15 +174,12 @@ namespace GlitchyEngine
_window.Context.SetPrimitiveTopology(.TriangleList);
var _immediateContext = _window.Context.[Friend]nativeContext;
_window.Context.SetVertexShader(_vertexShader);
_window.Context.SetRasterizerState(_rasterizerState);
_window.Context.SetViewport(Window.Context.SwapChain.BackbufferViewport);
_immediateContext.PixelShader.SetConstantBuffers(0, 1, &_cBuffer.[Friend]nativeBuffer);
_window.Context.SetPixelShader(_pixelShader);
_window.Context.DrawIndexed(3 * 6);