git.s-ol.nu glsl-view / 66d7da0
update for zig 0.7.1 s-ol 8 months ago
5 changed file(s) with 8 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
33 const mode = b.standardReleaseOptions();
44 const exe = b.addExecutable("t", "src/main.zig");
55 exe.setBuildMode(mode);
6 exe.linkSystemLibrary("c");
7 exe.linkSystemLibrary("yaml");
8 exe.linkSystemLibrary("glfw");
6 exe.linkLibC();
7 exe.linkSystemLibrary("yaml-0.1");
8 exe.linkSystemLibrary("glfw3");
99 exe.linkSystemLibrary("epoxy");
10 exe.linkSystemLibrary("lo");
10 exe.linkSystemLibrary("liblo");
1111 exe.install();
1212
1313 const run_cmd = exe.run();
11 const gl = @import("gl.zig");
22 const std = @import("std");
33 const cfg = @import("config.zig");
4
5 const param_prefix = "/param/";
64
75 fn verify_args(expected: u8, got: []const u8) !void {
86 for (got) |typ| {
7068 .udp => c.LO_UDP,
7169 .tcp => c.LO_TCP,
7270 .unix => c.LO_UNIX,
73 else => unreachable,
7471 };
7572
7673 std.debug.warn(
8380 std.debug.warn("listening for OSC messages at {s}\n", .{url});
8481 self.server = c.lo_server_new_from_url(url[0..].ptr, handle_error);
8582 },
86 else => unreachable,
8783 }
8884
8985 if (self.server == null)
233233 .DOUBLE_MAT4x2 => |*value| c.glProgramUniformMatrix4x2dv(program, location, 1, c.GL_FALSE, value),
234234 .DOUBLE_MAT4x3 => |*value| c.glProgramUniformMatrix4x3dv(program, location, 1, c.GL_FALSE, value),
235235 .SAMPLER_1D, .SAMPLER_2D, .SAMPLER_3D, .SAMPLER_CUBE, .SAMPLER_1D_SHADOW, .SAMPLER_2D_SHADOW, .SAMPLER_1D_ARRAY, .SAMPLER_2D_ARRAY, .SAMPLER_1D_ARRAY_SHADOW, .SAMPLER_2D_ARRAY_SHADOW, .SAMPLER_2D_MULTISAMPLE, .SAMPLER_2D_MULTISAMPLE_ARRAY, .SAMPLER_CUBE_SHADOW, .SAMPLER_BUFFER, .SAMPLER_2D_RECT, .SAMPLER_2D_RECT_SHADOW, .INT_SAMPLER_1D, .INT_SAMPLER_2D, .INT_SAMPLER_3D, .INT_SAMPLER_CUBE, .INT_SAMPLER_1D_ARRAY, .INT_SAMPLER_2D_ARRAY, .INT_SAMPLER_2D_MULTISAMPLE, .INT_SAMPLER_2D_MULTISAMPLE_ARRAY, .INT_SAMPLER_BUFFER, .INT_SAMPLER_2D_RECT, .UNSIGNED_INT_SAMPLER_1D, .UNSIGNED_INT_SAMPLER_2D, .UNSIGNED_INT_SAMPLER_3D, .UNSIGNED_INT_SAMPLER_CUBE, .UNSIGNED_INT_SAMPLER_1D_ARRAY, .UNSIGNED_INT_SAMPLER_2D_ARRAY, .UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, .UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, .UNSIGNED_INT_SAMPLER_BUFFER, .UNSIGNED_INT_SAMPLER_2D_RECT => |value| c.glProgramUniform1i(program, location, value),
236 else => unreachable,
237236 }
238237 }
239238
281280 .DOUBLE_MAT4x2 => |*value| c.glGetUniformdv(program, location, value),
282281 .DOUBLE_MAT4x3 => |*value| c.glGetUniformdv(program, location, value),
283282 .SAMPLER_1D, .SAMPLER_2D, .SAMPLER_3D, .SAMPLER_CUBE, .SAMPLER_1D_SHADOW, .SAMPLER_2D_SHADOW, .SAMPLER_1D_ARRAY, .SAMPLER_2D_ARRAY, .SAMPLER_1D_ARRAY_SHADOW, .SAMPLER_2D_ARRAY_SHADOW, .SAMPLER_2D_MULTISAMPLE, .SAMPLER_2D_MULTISAMPLE_ARRAY, .SAMPLER_CUBE_SHADOW, .SAMPLER_BUFFER, .SAMPLER_2D_RECT, .SAMPLER_2D_RECT_SHADOW, .INT_SAMPLER_1D, .INT_SAMPLER_2D, .INT_SAMPLER_3D, .INT_SAMPLER_CUBE, .INT_SAMPLER_1D_ARRAY, .INT_SAMPLER_2D_ARRAY, .INT_SAMPLER_2D_MULTISAMPLE, .INT_SAMPLER_2D_MULTISAMPLE_ARRAY, .INT_SAMPLER_BUFFER, .INT_SAMPLER_2D_RECT, .UNSIGNED_INT_SAMPLER_1D, .UNSIGNED_INT_SAMPLER_2D, .UNSIGNED_INT_SAMPLER_3D, .UNSIGNED_INT_SAMPLER_CUBE, .UNSIGNED_INT_SAMPLER_1D_ARRAY, .UNSIGNED_INT_SAMPLER_2D_ARRAY, .UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, .UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, .UNSIGNED_INT_SAMPLER_BUFFER, .UNSIGNED_INT_SAMPLER_2D_RECT => |*value| c.glGetnUniformiv(program, location, @sizeOf(@TypeOf(value.*)), value),
284 else => unreachable,
285283 }
286284 }
287285 // zig fmt: on
363361 self.allocator.free(entry.key);
364362 }
365363
366 self.uniforms.clear();
367364 self.uniforms.deinit();
368365 }
369366
403400 self.allocator.free(removed.key);
404401 }
405402 } else {
406 var uniform = self.uniforms.get(name).?.value;
403 var uniform = self.uniforms.get(name).?;
407404 uniform.location = self.shader.uniformLocation(name.ptr) catch unreachable;
408405 uniform.setShaderValue(self.shader.*);
409406 }
417414
418415 var result = try self.uniforms.getOrPut(cloned_name);
419416 if (!result.found_existing) {
420 result.kv.value = CachedUniform.init(self.shader.*, name.ptr) catch {
417 result.entry.value = CachedUniform.init(self.shader.*, name.ptr) catch {
421418 _ = self.uniforms.remove(cloned_name);
422419 self.allocator.free(cloned_name);
423420 return null;
424421 };
425422 }
426423
427 return &result.kv.value;
424 return &result.entry.value;
428425 }
429426 };
430427
171171 \\}
172172 ;
173173
174 if (gl.ShaderProgram.create(vert_source, frag_source[0..length])) |new_program| {
174 if (gl.ShaderProgram.create(vert_source, frag_source)) |new_program| {
175175 current.destroy();
176176 current.* = new_program;
177177 } else |err| {
2020 ) *Output {
2121 return switch (config.type) {
2222 .window => WindowOutput.create(allocator, config, constants),
23 else => unreachable,
2423 };
2524 }
2625 };