Uniforms and compiling shaders with a script

This commit is contained in:
nothke
2024-06-11 20:43:41 +02:00
parent a8dd27f3a4
commit e2a9053866
4 changed files with 628 additions and 2 deletions

View File

@@ -3,13 +3,14 @@ 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 = .{};
const state = struct {
var bind: sg.Bindings = .{};
var pip: sg.Pipeline = .{};
var vsParams: shader.FsParams = .{ .offset = .{ 0, 0, 0 } };
};
export fn init() void {
@@ -57,9 +58,13 @@ 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.applyPipeline(state.pip);
sg.applyBindings(state.bind);
sg.applyUniforms(.FS, shader.SLOT_fs_params, sg.asRange(&state.vsParams));
sg.draw(0, 3, 1);
sg.endPass();
sg.commit();