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:21:51 -07:00
|
|
|
// The major version number of the GLFW library.
|
|
|
|
//
|
|
|
|
// This is incremented when the API is changed in non-compatible ways.
|
|
|
|
pub const version_major = c.GLFW_VERSION_MAJOR;
|
|
|
|
|
|
|
|
// The minor version number of the GLFW library.
|
|
|
|
//
|
|
|
|
// This is incremented when features are added to the API but it remains backward-compatible.
|
|
|
|
pub const version_minor = c.GLFW_VERSION_MINOR;
|
|
|
|
|
|
|
|
// The revision number of the GLFW library.
|
|
|
|
//
|
|
|
|
// This is incremented when a bug fix release is made that does not contain any API changes.
|
|
|
|
pub const version_revision = c.GLFW_VERSION_REVISION;
|
|
|
|
|
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" {
|
|
|
|
std.debug.print("\nGLFW version v{}.{}.{}\n", .{version_major, version_minor, version_revision});
|
|
|
|
}
|
|
|
|
|
2021-07-06 20:53:10 -07:00
|
|
|
test "basic" {
|
|
|
|
basicTest();
|
|
|
|
}
|