aboutsummaryrefslogtreecommitdiffstats
path: root/src/output.zig
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2023-10-27 18:29:26 +0000
committers-ol <s+removethis@s-ol.nu>2023-10-29 22:43:58 +0000
commita250d5bbe6eb215e345de4900e784140dfe73161 (patch)
tree3a9f3aa116f7d0ac2faca30b6ceab6a110d6eef2 /src/output.zig
parentupdate for zig 0.9.0 (diff)
downloadglsl-view-a250d5bbe6eb215e345de4900e784140dfe73161.tar.gz
glsl-view-a250d5bbe6eb215e345de4900e784140dfe73161.zip
update for zig 0.11.0
Diffstat (limited to 'src/output.zig')
-rw-r--r--src/output.zig23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/output.zig b/src/output.zig
index f4c33d7..96b3f3e 100644
--- a/src/output.zig
+++ b/src/output.zig
@@ -4,10 +4,10 @@ const cfg = @import("config.zig");
const gl = @import("gl.zig");
pub const Output = struct {
- update: fn (*Output, c.GLuint) bool,
- destroy: fn (*Output) void,
+ update: *const fn (*Output, c.GLuint) bool,
+ destroy: *const fn (*Output) void,
- fn init(update: fn (*Output, c.GLuint) bool, destroy: fn (*Output) void) Output {
+ fn init(update: *const fn (*Output, c.GLuint) bool, destroy: *const fn (*Output) void) Output {
return Output{
.update = update,
.destroy = destroy,
@@ -15,7 +15,7 @@ pub const Output = struct {
}
pub fn create(
- allocator: *std.mem.Allocator,
+ allocator: std.mem.Allocator,
config: cfg.OutputConfig,
constants: *gl.Constants,
) *Output {
@@ -33,7 +33,7 @@ pub const WindowOutput = struct {
resized: bool = false,
pub fn create(
- allocator: *std.mem.Allocator,
+ allocator: std.mem.Allocator,
config: cfg.OutputConfig,
constants: *gl.Constants,
) *Output {
@@ -55,7 +55,7 @@ pub const WindowOutput = struct {
},
};
- c.glfwSetWindowUserPointer(self.window, @ptrCast(*c_void, self));
+ c.glfwSetWindowUserPointer(self.window, @as(*anyopaque, @ptrCast(self)));
_ = c.glfwSetKeyCallback(self.window, keyCallback);
_ = c.glfwSetFramebufferSizeCallback(self.window, sizeCallback);
@@ -81,13 +81,13 @@ pub const WindowOutput = struct {
var scaled_height: c_int = undefined;
c.glfwGetFramebufferSize(self.window, &width, &height);
- const window_aspect = @intToFloat(f32, width) / @intToFloat(f32, height);
+ const window_aspect = @as(f32, @floatFromInt(width)) / @as(f32, @floatFromInt(height));
if (window_aspect >= self.constants.aspect) {
scaled_height = height;
- scaled_width = @floatToInt(c_int, @intToFloat(f32, height) * self.constants.aspect);
+ scaled_width = @as(c_int, @intFromFloat(@as(f32, @floatFromInt(height)) * self.constants.aspect));
} else {
scaled_width = width;
- scaled_height = @floatToInt(c_int, @intToFloat(f32, width) / self.constants.aspect);
+ scaled_height = @as(c_int, @intFromFloat(@as(f32, @floatFromInt(width)) / self.constants.aspect));
}
c.glViewport(
@@ -123,11 +123,10 @@ pub const WindowOutput = struct {
) callconv(.C) void {
if (action != c.GLFW_PRESS) return;
const userptr = c.glfwGetWindowUserPointer(win).?;
- const self = @ptrCast(*WindowOutput, @alignCast(@alignOf(WindowOutput), userptr));
+ const self = @as(*WindowOutput, @ptrCast(@alignCast(userptr)));
_ = self;
_ = scancode;
- _ = action;
_ = mods;
switch (key) {
@@ -140,7 +139,7 @@ pub const WindowOutput = struct {
fn sizeCallback(win: ?*c.GLFWwindow, width: c_int, height: c_int) callconv(.C) void {
const userptr = c.glfwGetWindowUserPointer(win).?;
- const self = @ptrCast(*WindowOutput, @alignCast(@alignOf(WindowOutput), userptr));
+ const self = @as(*WindowOutput, @ptrCast(@alignCast(userptr)));
self.resized = true;
_ = width;