diff options
| author | s-ol <s+removethis@s-ol.nu> | 2025-08-05 01:06:40 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-08-05 01:06:40 +0000 |
| commit | 7a49ce08279622f63f0037294fdf299ef9c43c78 (patch) | |
| tree | b739290b5741f634f8fd2a62b5bee04886294568 | |
| parent | dynamic OSC method registration for sources (diff) | |
| download | glsl-view-7a49ce08279622f63f0037294fdf299ef9c43c78.tar.gz glsl-view-7a49ce08279622f63f0037294fdf299ef9c43c78.zip | |
fix boolean uniforms
| -rw-r--r-- | src/control.zig | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/control.zig b/src/control.zig index 71e688a..96efa9a 100644 --- a/src/control.zig +++ b/src/control.zig @@ -9,7 +9,7 @@ const build_config = @import("build_config"); fn verify_args(expected: u8, got: []const u8) !void { for (got) |typ| { if (typ != expected) { - std.debug.print("expected '{c}' but got '{c}' element (expected {s})\n", .{ expected, typ, got }); + std.debug.print("expected '{c}' but got '{c}' element (args are {s})\n", .{ expected, typ, got }); return error.typeMismatch; } } @@ -17,7 +17,7 @@ fn verify_args(expected: u8, got: []const u8) !void { fn set_one( comptime T: type, - dest: *T, + dest: *(if (T == bool) c.GLuint else T), argv: []const [*c]c.lo_arg, types: []const u8, ) !void { @@ -44,13 +44,20 @@ fn set_one( return error.signDisallowed; dest.* = @as(u32, @intCast(val)); }, + bool => { + dest.* = switch (types[0]) { + 'T' => c.GL_TRUE, + 'F' => c.GL_FALSE, + else => return error.typeMismatch, + }; + }, else => return error.invalidType, } } fn set_array( comptime T: type, - dest: []T, + dest: [](if (T == bool) c.GLuint else T), argv: []const [*c]c.lo_arg, types: []const u8, ) !void { @@ -272,7 +279,7 @@ pub const ControlServer = struct { .DOUBLE => |val| set_one(f64, val, argv, types), .INT => |val| set_one(i32, val, argv, types), .UNSIGNED_INT => |val| set_one(u32, val, argv, types), - .BOOL => |val| set_one(u32, val, argv, types), + .BOOL => |val| set_one(bool, val, argv, types), .FLOAT_VEC2 => |val| set_array(f32, val.*[0..], argv, types), .FLOAT_VEC3 => |val| set_array(f32, val.*[0..], argv, types), .FLOAT_VEC4 => |val| set_array(f32, val.*[0..], argv, types), @@ -285,9 +292,9 @@ pub const ControlServer = struct { .UNSIGNED_INT_VEC2 => |val| set_array(u32, val.*[0..], argv, types), .UNSIGNED_INT_VEC3 => |val| set_array(u32, val.*[0..], argv, types), .UNSIGNED_INT_VEC4 => |val| set_array(u32, val.*[0..], argv, types), - .BOOL_VEC2 => |val| set_array(u32, val.*[0..], argv, types), - .BOOL_VEC3 => |val| set_array(u32, val.*[0..], argv, types), - .BOOL_VEC4 => |val| set_array(u32, val.*[0..], argv, types), + .BOOL_VEC2 => |val| set_array(bool, val.*[0..], argv, types), + .BOOL_VEC3 => |val| set_array(bool, val.*[0..], argv, types), + .BOOL_VEC4 => |val| set_array(bool, val.*[0..], argv, types), .FLOAT_MAT2 => |val| set_array(f32, val.*[0..], argv, types), .FLOAT_MAT3 => |val| set_array(f32, val.*[0..], argv, types), .FLOAT_MAT4 => |val| set_array(f32, val.*[0..], argv, types), |
