OpenGL loader interface, bindings and optional type-safe wrapper for Zig.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Chris Heyes 447f69e5c9
Update main.yml
Run CI with Zig 0.16.0 and 0.17.0
2026-10-24 13:21:11 +01:00
.github/workflows Update main.yml 2026-10-24 13:21:11 +01:00
src Various adjustments and improvements to wrapper.zig (#35) 2026-07-19 13:40:42 +01:00
.gitignore files from monorepo @ 14e6258901c6fb47ae598705682837ef6c298e60 2024-11-03 23:34:37 +00:00
build.zig Allow defining zopengl export-linkage at build time (#33) 2026-02-12 17:43:58 +00:00
build.zig.zon Update to Zig 0.16.0 (#34) 2026-05-02 11:47:34 +01:00
LICENSE files from monorepo @ 14e6258901c6fb47ae598705682837ef6c298e60 2024-11-03 23:34:37 +00:00
README.md Update README.md 2025-10-23 02:59:09 +01:00

zopengl

OpenGL loader interface, bindings and optional type-safe wrapper for Zig.

Supports:

  • OpenGL Core Profile up to version 4.6
  • OpenGL ES up to version 2.0

Getting started

Example build.zig:

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

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

Now in your code you may import and use zopengl:

const zopengl = @import("zopengl");

pub fn main() !void {
    // Create window and OpenGL context here... (you can use our `zsdl` or `zglfw` libs for this)

    try zopengl.loadCoreProfile(getProcAddress, 4, 0);

    const gl = zopengl.bindings; // or zopengl.wrapper (experimental)

    gl.clearBufferfv(gl.COLOR, 0, &.{ 0.2, 0.4, 0.8, 1.0 });
}

fn getProcAddress(name: [*:0]const u8) callconv(.c) ?*const anyopaque {
    // Load GL function pointer here
    // You could use `zsdl.gl.getProcAddress() or `zglfw.getProcAddress()`
}