Merge branch 'uniforms'
This commit is contained in:
@@ -3,7 +3,7 @@ const sokol = @import("sokol");
|
||||
|
||||
const sg = sokol.gfx;
|
||||
|
||||
const shader = @import("shaders/triangle.glsl.zig");
|
||||
const shader = @import("shaders/triangle2.glsl.zig");
|
||||
|
||||
var pass_action: sg.PassAction = .{};
|
||||
|
||||
@@ -11,6 +11,7 @@ const state = struct {
|
||||
var bind: sg.Bindings = .{};
|
||||
var bind2: sg.Bindings = .{};
|
||||
var pip: sg.Pipeline = .{};
|
||||
var vsParams: shader.FsParams = .{ .offset = .{ 0, 0, 0 } };
|
||||
};
|
||||
|
||||
export fn init() void {
|
||||
@@ -68,10 +69,14 @@ export fn frame() void {
|
||||
col.g = @abs(@sin(timef()));
|
||||
col.r = @abs(@cos(timef()));
|
||||
|
||||
state.vsParams.offset[0] = col.r;
|
||||
|
||||
sg.beginPass(.{ .action = pass_action, .swapchain = sokol.glue.swapchain() });
|
||||
sg.asRange(3);
|
||||
sg.applyPipeline(state.pip);
|
||||
sg.applyBindings(state.bind);
|
||||
|
||||
sg.applyUniforms(.FS, shader.SLOT_fs_params, sg.asRange(&state.vsParams));
|
||||
sg.draw(0, 3, 1);
|
||||
sg.applyBindings(state.bind2);
|
||||
sg.draw(0, 3, 1);
|
||||
|
Reference in New Issue
Block a user