glfw: fix and test VideoMode getters

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-07-17 20:56:48 -07:00
parent 5238e52d76
commit 72f09b4f32
2 changed files with 14 additions and 0 deletions

View file

@ -5,6 +5,8 @@
const std = @import("std"); const std = @import("std");
const c = @import("c.zig").c; const c = @import("c.zig").c;
const VideoMode = @This();
handle: c.GLFWvidmode, handle: c.GLFWvidmode,
/// Returns the width of the video mode, in screen coordinates. /// Returns the width of the video mode, in screen coordinates.
@ -36,3 +38,13 @@ pub inline fn getBlueBits(self: VideoMode) usize {
pub inline fn getRefreshRate(self: VideoMode) usize { pub inline fn getRefreshRate(self: VideoMode) usize {
return @intCast(usize, self.handle.refreshRate); return @intCast(usize, self.handle.refreshRate);
} }
test "getters" {
const x = std.mem.zeroes(VideoMode);
_ = x.getWidth();
_ = x.getHeight();
_ = x.getRedBits();
_ = x.getGreenBits();
_ = x.getBlueBits();
_ = x.getRefreshRate();
}

View file

@ -17,6 +17,7 @@ pub const mod = @import("mod.zig");
pub const Monitor = @import("Monitor.zig"); pub const Monitor = @import("Monitor.zig");
pub const mouse_button = @import("mouse_button.zig"); pub const mouse_button = @import("mouse_button.zig");
pub const version = @import("version.zig"); pub const version = @import("version.zig");
pub const VideoMode = @import("VideoMode.zig");
/// Initializes the GLFW library. /// Initializes the GLFW library.
/// ///
@ -142,5 +143,6 @@ test "version" {
test "basic" { test "basic" {
_ = Monitor; _ = Monitor;
_ = VideoMode;
basicTest() catch unreachable; basicTest() catch unreachable;
} }