Add 'package-glfw/' from commit 'a8f2a899cdd0bb4316b7d50f2ee3296bf6fb208f'
git-subtree-dir: package-glfw git-subtree-mainline:cddb3ce509
git-subtree-split:a8f2a899cd
This commit is contained in:
25
package-glfw/src/main.zig
Normal file
25
package-glfw/src/main.zig
Normal file
@@ -0,0 +1,25 @@
|
||||
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user