glfw: use Window.create in basic test

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-07-18 21:36:14 -07:00
parent 9359bdc273
commit c2af312200

View file

@ -124,21 +124,18 @@ pub fn basicTest() !void {
try init(); try init();
defer terminate(); defer terminate();
c.glfwWindowHint(c.GLFW_VISIBLE, c.GLFW_FALSE); const window = Window.create(640, 480, "GLFW example", null, null) catch |err| {
const window = c.glfwCreateWindow(640, 480, "GLFW example", null, null);
if (window == null) {
// return without fail, because most of our CI environments are headless / we cannot open // return without fail, because most of our CI environments are headless / we cannot open
// windows on them. // windows on them.
std.debug.print("note: failed to create window", .{}); std.debug.print("note: failed to create window: {}\n", .{err});
return; return;
} };
defer c.glfwDestroyWindow(window.handle);
var start = std.time.milliTimestamp(); var start = std.time.milliTimestamp();
while (std.time.milliTimestamp() < start + 100 and c.glfwWindowShouldClose(window) != c.GLFW_TRUE) { while (std.time.milliTimestamp() < start + 1000 and c.glfwWindowShouldClose(window.handle) != c.GLFW_TRUE) {
c.glfwPollEvents(); c.glfwPollEvents();
} }
c.glfwDestroyWindow(window);
} }
test "version" { test "version" {