glfw: add basic example, building+linking on macOS is working
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
e7e8567a7a
commit
6e5ff09e55
2 changed files with 156 additions and 0 deletions
28
glfw/src/main.zig
Normal file
28
glfw/src/main.zig
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
|
||||
pub fn basicTest() void {
|
||||
if (c.glfwInit() != c.GLFW_TRUE) {
|
||||
@panic("failed to init");
|
||||
}
|
||||
const window = c.glfwCreateWindow(640, 480, "GLFW example", null, null);
|
||||
if (window == null)
|
||||
{
|
||||
c.glfwTerminate();
|
||||
@panic("failed to create window");
|
||||
}
|
||||
|
||||
var start = std.time.milliTimestamp();
|
||||
while (std.time.milliTimestamp() < start+3000 and c.glfwWindowShouldClose(window) != c.GLFW_TRUE) {
|
||||
c.glfwPollEvents();
|
||||
}
|
||||
|
||||
c.glfwDestroyWindow(window);
|
||||
c.glfwTerminate();
|
||||
}
|
||||
|
||||
test "basic" {
|
||||
basicTest();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue