git.s-ol.nu glsl-view / master
update for zig 0.8.1 s-ol 7 months ago
5 changed file(s) with 19 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
9999 } else if (std.mem.eql(u8, key, "osc")) {
100100 config.osc = try parseOSC(&parser, allocator);
101101 } else {
102 debug.warn("unknown key: '{}'\n", .{key});
102 debug.warn("unknown key: '{s}'\n", .{key});
103103 try skipAny(&parser);
104104 }
105105 },
240240 } else if (std.mem.eql(u8, key, "fullscreen")) {
241241 output.*.fullscreen = try parseBool(parser);
242242 } else {
243 debug.warn("unknown key: '{}'\n", .{key});
243 debug.warn("unknown key: '{s}'\n", .{key});
244244 try skipAny(parser);
245245 }
246246 },
302302 param.*.type = try parseString(parser, allocator);
303303 have_type = true;
304304 } else {
305 debug.warn("unknown key: '{}'\n", .{key});
305 debug.warn("unknown key: '{s}'\n", .{key});
306306 try skipAny(parser);
307307 }
308308 },
363363 } else if (std.mem.eql(u8, key, "port")) {
364364 config.Manual.port = try parseInt(parser, u16);
365365 } else {
366 debug.warn("unknown key: '{}'\n", .{key});
366 debug.warn("unknown key: '{s}'\n", .{key});
367367 try skipAny(parser);
368368 }
369369 },
55 fn verify_args(expected: u8, got: []const u8) !void {
66 for (got) |typ| {
77 if (typ != expected) {
8 std.debug.warn("expected '{c}' but got '{c}' element (expected {})\n", .{expected, typ, got});
8 std.debug.warn("expected '{c}' but got '{c}' element (expected {s})\n", .{ expected, typ, got });
99 return error.typeMismatch;
1010 }
1111 }
182182 }
183183
184184 self.set_uniform(path[1..], argv, argc, types) catch |err| {
185 std.debug.warn("{} while processing {}\n", .{err, path});
185 std.debug.warn("{s} while processing {s}\n", .{ err, path });
186186 };
187187 return 0;
188188 }
33 const panic = std.debug.panic;
44 const builtin = @import("builtin");
55
6 pub const is_on = if (builtin.mode == builtin.Mode.ReleaseFast) c.GL_FALSE else c.GL_TRUE;
6 pub const is_on = if (builtin.mode == std.builtin.Mode.ReleaseFast) c.GL_FALSE else c.GL_TRUE;
77
88 fn glDebugMessage(
99 source: c.GLenum,
358358 pub fn deinit(self: *UniformCache) void {
359359 var it = self.uniforms.iterator();
360360 while (it.next()) |entry| {
361 self.allocator.free(entry.key);
361 self.allocator.free(entry.key_ptr.*);
362362 }
363363
364364 self.uniforms.deinit();
380380 var it = self.uniforms.iterator();
381381 var i: usize = 0;
382382 while (it.next()) |entry| {
383 existing_names[i] = entry.key;
384 existing_names_c[i] = entry.key.ptr;
383 existing_names[i] = entry.key_ptr.*;
384 existing_names_c[i] = entry.key_ptr.*.ptr;
385385 i += 1;
386386 }
387387 }
396396 for (existing_indices) |index, i| {
397397 const name = existing_names[i];
398398 if (index == c.GL_INVALID_INDEX) {
399 if (self.uniforms.remove(name)) |removed| {
399 if (self.uniforms.fetchRemove(name)) |removed| {
400400 self.allocator.free(removed.key);
401401 }
402402 } else {
414414
415415 var result = try self.uniforms.getOrPut(cloned_name);
416416 if (!result.found_existing) {
417 result.entry.value = CachedUniform.init(self.shader.*, name.ptr) catch {
417 result.value_ptr.* = CachedUniform.init(self.shader.*, name.ptr) catch {
418418 _ = self.uniforms.remove(cloned_name);
419419 self.allocator.free(cloned_name);
420420 return null;
421421 };
422422 }
423423
424 return &result.entry.value;
424 return result.value_ptr;
425425 }
426426 };
427427
1111 var window: *c.GLFWwindow = undefined;
1212
1313 fn errorCallback(err: c_int, description: [*c]const u8) callconv(.C) void {
14 panic("Error: {}\n", .{description});
14 panic("Error: {s}\n", .{description});
1515 }
1616
1717 pub fn main() !void {
176176 if (std.mem.eql(u8, pragma, "include")) {
177177 var include_path = parts.next().?;
178178 if (include_path[0] != '"' or include_path[include_path.len - 1] != '"') {
179 std.debug.warn("Invalid #pragma directive '{}'\n", .{line});
179 std.debug.warn("Invalid #pragma directive '{s}'\n", .{line});
180180 continue;
181181 }
182182 include_path = include_path[1 .. include_path.len - 1];
185185
186186 continue;
187187 } else {
188 std.debug.warn("Unknown #pragma directive '{}'\n", .{pragma});
188 std.debug.warn("Unknown #pragma directive '{s}'\n", .{pragma});
189189 }
190190 }
191191
220220 current.destroy();
221221 current.* = new_program;
222222 } else |err| {
223 std.debug.warn("Error while reloading shader:{}\n", .{err});
224 }
225 }
223 std.debug.warn("Error while reloading shader: {s}\n", .{err});
224 }
225 }