Files
zig-experiments/package-glfw/src/main.zig
David Allemang c147c624a7 Add 'package-glfw/' from commit 'a8f2a899cdd0bb4316b7d50f2ee3296bf6fb208f'
git-subtree-dir: package-glfw
git-subtree-mainline: cddb3ce509
git-subtree-split: a8f2a899cd
2025-08-04 22:14:49 -04:00

26 lines
548 B
Zig

const std = @import("std");
const c = @cImport({
@cInclude("GLFW/glfw3.h");
});
pub fn main() !void {
if (c.glfwInit() == 0) {
@panic("GLFW Initialization failed");
}
defer c.glfwTerminate();
// todo error callback
const win = c.glfwCreateWindow(640, 480, "Hello Zig!", null, null);
if (win == null) {
@panic("GLFW window creation failed");
}
defer c.glfwDestroyWindow(win);
while (c.glfwWindowShouldClose(win) == 0) {
c.glfwPollEvents();
c.glfwSwapBuffers(win);
}
}