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 {
|
const state = struct {
|
||||||
var bind: sg.Bindings = .{};
|
var bind: sg.Bindings = .{};
|
||||||
var bind2: sg.Bindings = .{};
|
|
||||||
var pip: sg.Pipeline = .{};
|
var pip: sg.Pipeline = .{};
|
||||||
var vsParams: shader.FsParams = .{ .offset = .{ 0, 0, 0 } };
|
var vsParams: shader.FsParams = .{ .offset = .{ 0, 0, 0 } };
|
||||||
};
|
};
|
||||||
@ -35,15 +34,13 @@ export fn init() void {
|
|||||||
.data = sg.asRange(&triangleVerts),
|
.data = sg.asRange(&triangleVerts),
|
||||||
});
|
});
|
||||||
|
|
||||||
for (&triangleVerts) |*vert| {
|
state.bind.index_buffer = sg.makeBuffer(.{
|
||||||
vert.* += 0.2;
|
.type = .INDEXBUFFER,
|
||||||
}
|
.data = sg.asRange(&[_]u16{ 0, 1, 2 }),
|
||||||
|
|
||||||
state.bind2.vertex_buffers[0] = sg.makeBuffer(.{
|
|
||||||
.data = sg.asRange(&triangleVerts),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var pip_desc: sg.PipelineDesc = .{
|
var pip_desc: sg.PipelineDesc = .{
|
||||||
|
.index_type = .UINT16,
|
||||||
.shader = sg.makeShader(shader.triangleShaderDesc(sg.queryBackend())),
|
.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.applyUniforms(.FS, shader.SLOT_fs_params, sg.asRange(&state.vsParams));
|
||||||
sg.applyBindings(state.bind);
|
sg.applyBindings(state.bind);
|
||||||
sg.draw(0, 3, 1);
|
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.endPass();
|
||||||
|
|
||||||
sg.commit();
|
sg.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user