Stream: Now doing indexed rendering
This commit is contained in:
parent
c4c104538b
commit
d8f5c9bb61
17
src/main.zig
17
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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user