diff --git a/src/glfw/glfw.zig b/src/glfw/glfw.zig new file mode 100644 index 000000000..baea33ebe --- /dev/null +++ b/src/glfw/glfw.zig @@ -0,0 +1,2 @@ +pub const c = @import("c.zig"); +pub const errors = @import("errors.zig"); diff --git a/src/main.zig b/src/main.zig index f10f3f0e9..fd8a78948 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,7 +1,20 @@ const std = @import("std"); -const c = @import("glfw/c.zig"); +const glfw = @import("glfw/glfw.zig"); pub fn main() !void { - if (c.glfwInit() != c.GLFW_TRUE) return error.GlfwInitFailed; - defer c.glfwTerminate(); + // Iniialize GLFW + if (glfw.c.glfwInit() != glfw.c.GLFW_TRUE) return glfw.errors.getError(); + defer glfw.c.glfwTerminate(); + + // Create our initial window + const window = glfw.c.glfwCreateWindow(640, 480, "My Title", null, null) orelse + return glfw.errors.getError(); + defer glfw.c.glfwDestroyWindow(window); + + // Setup OpenGL + glfw.c.glfwMakeContextCurrent(window); + + while (glfw.c.glfwWindowShouldClose(window) == glfw.c.GLFW_FALSE) { + glfw.c.glfwWaitEvents(); + } }