From d8f5c9bb615a3317b1e8f6942d866744e4940df0 Mon Sep 17 00:00:00 2001 From: nothke Date: Wed, 12 Jun 2024 00:29:16 +0200 Subject: [PATCH] Stream: Now doing indexed rendering --- src/main.zig | 17 +++++------------ todo.todo | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 todo.todo diff --git a/src/main.zig b/src/main.zig index 5534d0e..1178943 100644 --- a/src/main.zig +++ b/src/main.zig @@ -9,7 +9,6 @@ var pass_action: sg.PassAction = .{}; const state = struct { var bind: sg.Bindings = .{}; - var bind2: sg.Bindings = .{}; var pip: sg.Pipeline = .{}; var vsParams: shader.FsParams = .{ .offset = .{ 0, 0, 0 } }; }; @@ -35,15 +34,13 @@ export fn init() void { .data = sg.asRange(&triangleVerts), }); - for (&triangleVerts) |*vert| { - vert.* += 0.2; - } - - state.bind2.vertex_buffers[0] = sg.makeBuffer(.{ - .data = sg.asRange(&triangleVerts), + state.bind.index_buffer = sg.makeBuffer(.{ + .type = .INDEXBUFFER, + .data = sg.asRange(&[_]u16{ 0, 1, 2 }), }); var pip_desc: sg.PipelineDesc = .{ + .index_type = .UINT16, .shader = sg.makeShader(shader.triangleShaderDesc(sg.queryBackend())), }; @@ -75,12 +72,8 @@ export fn frame() void { sg.applyUniforms(.FS, shader.SLOT_fs_params, sg.asRange(&state.vsParams)); sg.applyBindings(state.bind); sg.draw(0, 3, 1); - - state.vsParams.offset[0] = col.g; - sg.applyUniforms(.FS, shader.SLOT_fs_params, sg.asRange(&state.vsParams)); - sg.applyBindings(state.bind2); - sg.draw(0, 3, 1); sg.endPass(); + sg.commit(); } diff --git a/todo.todo b/todo.todo new file mode 100644 index 0000000..17757e4 --- /dev/null +++ b/todo.todo @@ -0,0 +1,15 @@ + + + +What are we doing here?: + ☐ using sokol in zig + ☐ part of a gamejam + +Today: + ☐ Guide through the code + + Draw a circle!: + ☐ Draw indices instead of triangle elements + ☐ Create a circle vertices + ☐ Draw the circle + ☐ Make the circle move with uniforms \ No newline at end of file