diff --git a/src/main.zig b/src/main.zig index 0833ad198..cb027225e 100644 --- a/src/main.zig +++ b/src/main.zig @@ -76,6 +76,7 @@ pub const Window = struct { std.log.err("GLFW Error({}): {s}", .{errorCode, description}); } fn keyCallback(_: ?*c.GLFWwindow, key: c_int, scancode: c_int, action: c_int, mods: c_int) callconv(.C) void { + _ = mods; if(action == c.GLFW_PRESS) { inline for(@typeInfo(@TypeOf(keyboard)).Struct.fields) |field| { if(key == @field(keyboard, field.name).key) { @@ -96,7 +97,6 @@ pub const Window = struct { } } } - std.log.info("Key pressed: {}, {}, {}, {}", .{key, scancode, action, mods}); } fn framebufferSize(_: ?*c.GLFWwindow, newWidth: c_int, newHeight: c_int) callconv(.C) void { std.log.info("Framebuffer: {}, {}", .{newWidth, newHeight}); @@ -129,10 +129,13 @@ pub const Window = struct { ignoreDataAfterRecentGrab = false; currentPos = newPos; } - fn glDebugOutput(_: c_uint, typ: c_uint, _: c_uint, severity: c_uint, length: c_int, message: [*c]const u8, _: ?*const anyopaque) callconv(.C) void { - if(typ == c.GL_DEBUG_TYPE_ERROR or typ == c.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR or typ == c.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR or typ == c.GL_DEBUG_TYPE_PORTABILITY or typ == c.GL_DEBUG_TYPE_PERFORMANCE) { + fn glDebugOutput(_: c_uint, _: c_uint, _: c_uint, severity: c_uint, length: c_int, message: [*c]const u8, _: ?*const anyopaque) callconv(.C) void { + if(severity == c.GL_DEBUG_SEVERITY_HIGH) { std.log.err("OpenGL {}:{s}", .{severity, message[0..@intCast(usize, length)]}); - @panic("OpenGL error"); + } else if(severity == c.GL_DEBUG_SEVERITY_MEDIUM) { + std.log.warn("OpenGL {}:{s}", .{severity, message[0..@intCast(usize, length)]}); + } else if(severity == c.GL_DEBUG_SEVERITY_LOW) { + std.log.info("OpenGL {}:{s}", .{severity, message[0..@intCast(usize, length)]}); } } }; diff --git a/src/network.zig b/src/network.zig index 3dc03af40..f20a9768c 100644 --- a/src/network.zig +++ b/src/network.zig @@ -1053,7 +1053,10 @@ pub const Protocols: struct { type_itemStackCollect => { const jsonObject = json.parseFromString(main.threadAllocator, data[1..]); defer jsonObject.free(main.threadAllocator); - const item = try items.Item.init(jsonObject); + const item = items.Item.init(jsonObject) catch |err| { + std.log.err("Error {s} while collecting item {s}. Ignoring it.", .{@errorName(err), data[1..]}); + return; + }; game.Player.mutex.lock(); defer game.Player.mutex.unlock(); const remaining = game.Player.inventory__SEND_CHANGES_TO_SERVER.addItem(item, jsonObject.get(u16, "amount", 0)); diff --git a/src/renderer.zig b/src/renderer.zig index 0c221e012..66db3dbd6 100644 --- a/src/renderer.zig +++ b/src/renderer.zig @@ -795,10 +795,8 @@ pub const MeshSelection = struct { @intToFloat(f32, voxelModel.maxZ)/16.0 ); - c.glLineWidth(2); c.glBindVertexArray(cubeVAO); - c.glDrawElements(c.GL_LINES, 12*2, c.GL_UNSIGNED_BYTE, null); - c.glLineWidth(1); + c.glDrawElements(c.GL_LINES, 12*2, c.GL_UNSIGNED_BYTE, null); // TODO: Draw thicker lines so they are more visible. Maybe a simple shader + cube mesh is enough. } } };