Skip to content
forked from zig-gamedev/zglfw

Zig build package and bindings for GLFW

License

Notifications You must be signed in to change notification settings

ckrowland/zglfw

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zig build package and bindings for GLFW 3.4

Getting started

Example build.zig:

pub fn build(b: *std.Build) void {
    const exe = b.addExecutable(.{ ... });

    const zglfw = b.dependency("zglfw", .{});
    exe.root_module.addImport("zglfw", zglfw.module("root"));

    if (target.result.os.tag != .emscrpten) {
        exe.linkLibrary(zglfw.artifact("glfw"));
    }
}

Now in your code you may import and use zglfw:

const glfw = @import("zglfw");

pub fn main() !void {
    try glfw.init();
    defer glfw.terminate();

    const window = try glfw.Window.create(600, 600, "zig-gamedev: minimal_glfw_gl", null);
    defer window.destroy();

    // setup your graphics context here

    while (!window.shouldClose()) {
        glfw.pollEvents();

        // render your things here
        
        window.swapBuffers();
    }
}

See zig-gamedev samples for more complete usage examples.

About

Zig build package and bindings for GLFW

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 90.3%
  • Objective-C 7.6%
  • Zig 2.1%