rendering a window

This commit is contained in:
Mitchell Hashimoto
2022-03-29 11:04:30 -07:00
parent b8cee0a39e
commit cc4d37804f
2 changed files with 18 additions and 3 deletions

2
src/glfw/glfw.zig Normal file
View File

@ -0,0 +1,2 @@
pub const c = @import("c.zig");
pub const errors = @import("errors.zig");

View File

@ -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();
}
}