Drawing a quad
This commit is contained in:
parent
d8f5c9bb61
commit
5ecc42ab89
13
src/main.zig
13
src/main.zig
@ -11,6 +11,7 @@ const state = struct {
|
||||
var bind: sg.Bindings = .{};
|
||||
var pip: sg.Pipeline = .{};
|
||||
var vsParams: shader.FsParams = .{ .offset = .{ 0, 0, 0 } };
|
||||
var indexCount: u16 = 0;
|
||||
};
|
||||
|
||||
export fn init() void {
|
||||
@ -28,15 +29,23 @@ export fn init() void {
|
||||
0.0, 0.5, 0.5, 1.0, 0.0, 0.0, 1.0,
|
||||
0.5, -0.5, 0.5, 0.0, 1.0, 0.0, 1.0,
|
||||
-0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0,
|
||||
0.7, 0.5, 0.5, 0.0, 1.0, 0.0, 1.0,
|
||||
};
|
||||
|
||||
state.bind.vertex_buffers[0] = sg.makeBuffer(.{
|
||||
.data = sg.asRange(&triangleVerts),
|
||||
});
|
||||
|
||||
const indexBuffer = [_]u16{
|
||||
0, 1, 2,
|
||||
0, 3, 1,
|
||||
};
|
||||
|
||||
state.indexCount = indexBuffer.len;
|
||||
|
||||
state.bind.index_buffer = sg.makeBuffer(.{
|
||||
.type = .INDEXBUFFER,
|
||||
.data = sg.asRange(&[_]u16{ 0, 1, 2 }),
|
||||
.data = sg.asRange(&indexBuffer),
|
||||
});
|
||||
|
||||
var pip_desc: sg.PipelineDesc = .{
|
||||
@ -71,7 +80,7 @@ export fn frame() void {
|
||||
state.vsParams.offset[0] = col.r;
|
||||
sg.applyUniforms(.FS, shader.SLOT_fs_params, sg.asRange(&state.vsParams));
|
||||
sg.applyBindings(state.bind);
|
||||
sg.draw(0, 3, 1);
|
||||
sg.draw(0, state.indexCount, 1);
|
||||
sg.endPass();
|
||||
|
||||
sg.commit();
|
||||
|
Loading…
Reference in New Issue
Block a user