From cc4d37804f7a5298551acaffe361ceced83cc323 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 29 Mar 2022 11:04:30 -0700 Subject: [PATCH] rendering a window --- src/glfw/glfw.zig | 2 ++ src/main.zig | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 src/glfw/glfw.zig 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(); + } }