2021-07-06 20:53:10 -07:00
|
|
|
const std = @import("std");
|
|
|
|
const testing = std.testing;
|
|
|
|
|
|
|
|
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
|
|
|
|
2021-07-16 11:33:46 -07:00
|
|
|
pub const action = @import("action.zig");
|
2021-07-16 11:40:32 -07:00
|
|
|
pub const hat = @import("hat.zig");
|
2021-07-16 12:11:12 -07:00
|
|
|
pub const key = @import("key.zig");
|
2021-07-16 11:40:32 -07:00
|
|
|
pub const version = @import("version.zig");
|
2021-07-16 11:31:02 -07:00
|
|
|
|
2021-07-06 20:53:10 -07:00
|
|
|
pub fn basicTest() void {
|
|
|
|
if (c.glfwInit() != c.GLFW_TRUE) {
|
|
|
|
@panic("failed to init");
|
|
|
|
}
|
2021-07-16 10:57:37 -07:00
|
|
|
c.glfwWindowHint(c.GLFW_VISIBLE, c.GLFW_FALSE);
|
2021-07-06 20:53:10 -07:00
|
|
|
const window = c.glfwCreateWindow(640, 480, "GLFW example", null, null);
|
2021-07-10 01:01:51 -07:00
|
|
|
if (window == null) {
|
2021-07-06 20:53:10 -07:00
|
|
|
c.glfwTerminate();
|
|
|
|
@panic("failed to create window");
|
|
|
|
}
|
|
|
|
|
|
|
|
var start = std.time.milliTimestamp();
|
2021-07-10 01:01:51 -07:00
|
|
|
while (std.time.milliTimestamp() < start + 3000 and c.glfwWindowShouldClose(window) != c.GLFW_TRUE) {
|
2021-07-06 20:53:10 -07:00
|
|
|
c.glfwPollEvents();
|
|
|
|
}
|
|
|
|
|
|
|
|
c.glfwDestroyWindow(window);
|
|
|
|
c.glfwTerminate();
|
|
|
|
}
|
|
|
|
|
2021-07-16 11:21:51 -07:00
|
|
|
test "version" {
|
2021-07-16 11:33:46 -07:00
|
|
|
std.debug.print("\nGLFW version v{}.{}.{}\n", .{ version.major, version.minor, version.revision });
|
2021-07-16 11:21:51 -07:00
|
|
|
}
|
|
|
|
|
2021-07-06 20:53:10 -07:00
|
|
|
test "basic" {
|
|
|
|
basicTest();
|
|
|
|
}
|