diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-06-08 09:32:17 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-06-08 09:32:17 +0000 |
| commit | 96d5ebf72ac395c57489b567c47d35d4807f1994 (patch) | |
| tree | bf6431a5ae276cd2e59b33c6ec56ebd9a4735195 /src/output.zig | |
| parent | error handling (diff) | |
| download | glsl-view-96d5ebf72ac395c57489b567c47d35d4807f1994.tar.gz glsl-view-96d5ebf72ac395c57489b567c47d35d4807f1994.zip | |
zig-fmt for low-column-screens
Diffstat (limited to 'src/output.zig')
| -rw-r--r-- | src/output.zig | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/src/output.zig b/src/output.zig index 770c0ba..5c8aa19 100644 --- a/src/output.zig +++ b/src/output.zig @@ -14,7 +14,11 @@ pub const Output = struct { }; } - pub fn create(allocator: *std.mem.Allocator, config: cfg.OutputConfig, constants: *gl.Constants) *Output { + pub fn create( + allocator: *std.mem.Allocator, + config: cfg.OutputConfig, + constants: *gl.Constants, + ) *Output { return switch (config.type) { .window => WindowOutput.create(allocator, config, constants), else => unreachable, @@ -29,7 +33,11 @@ pub const WindowOutput = struct { resized: bool = false, - pub fn create(allocator: *std.mem.Allocator, config: cfg.OutputConfig, constants: *gl.Constants) *Output { + pub fn create( + allocator: *std.mem.Allocator, + config: cfg.OutputConfig, + constants: *gl.Constants, + ) *Output { const self = allocator.create(WindowOutput) catch unreachable; c.glfwDefaultWindowHints(); @@ -37,7 +45,13 @@ pub const WindowOutput = struct { self.* = WindowOutput{ .constants = constants, .output = Output.init(update, destroy), - .window = c.glfwCreateWindow(config.width, config.height, "glsl-view output", null, constants.main_window) orelse { + .window = c.glfwCreateWindow( + config.width, + config.height, + "glsl-view output", + null, + constants.main_window, + ) orelse { std.debug.panic("unable to create output window\n", .{}); }, }; @@ -77,7 +91,12 @@ pub const WindowOutput = struct { scaled_height = @floatToInt(c_int, @intToFloat(f32, width) / self.constants.aspect); } - c.glViewport(@divFloor(width - scaled_width, 2), @divFloor(height - scaled_height, 2), scaled_width, scaled_height); + c.glViewport( + @divFloor(width - scaled_width, 2), + @divFloor(height - scaled_height, 2), + scaled_width, + scaled_height, + ); } c.glBindTexture(c.GL_TEXTURE_2D, texture_id); @@ -96,9 +115,16 @@ pub const WindowOutput = struct { c.glfwDestroyWindow(self.window); } - fn keyCallback(win: ?*c.GLFWwindow, key: c_int, scancode: c_int, action: c_int, mods: c_int) callconv(.C) void { + fn keyCallback( + win: ?*c.GLFWwindow, + key: c_int, + scancode: c_int, + action: c_int, + mods: c_int, + ) callconv(.C) void { if (action != c.GLFW_PRESS) return; - const self = @ptrCast(*WindowOutput, @alignCast(@alignOf(WindowOutput), c.glfwGetWindowUserPointer(win).?)); + const userptr = c.glfwGetWindowUserPointer(win).?; + const self = @ptrCast(*WindowOutput, @alignCast(@alignOf(WindowOutput), userptr)); switch (key) { // c.GLFW_KEY_F => // toggle fullscreen @@ -109,7 +135,8 @@ pub const WindowOutput = struct { } fn sizeCallback(win: ?*c.GLFWwindow, width: c_int, height: c_int) callconv(.C) void { - const self = @ptrCast(*WindowOutput, @alignCast(@alignOf(WindowOutput), c.glfwGetWindowUserPointer(win).?)); + const userptr = c.glfwGetWindowUserPointer(win).?; + const self = @ptrCast(*WindowOutput, @alignCast(@alignOf(WindowOutput), userptr)); self.resized = true; } }; |
