An OpenGL bindings generator for Zig. Includes dynamically loading.
In your build.zig, you can use the createBindingsModule method from the generator's build script:
const opengl_bindings_dependency = b.dependency("opengl_bindings", .{
.api = "gles2",
.version = "GL_ES_VERSION_3_0",
});
...
module.addImport("gl", opengl_bindings_dependency.module("gl"));Building the standalone binary is as simple as:
zig build -Doptimize=ReleaseFastYou can then run the generator with
./zig-out/bin/opengl-bindings gles2 GL_ES_VERSION_3_0 output.zigOnce the module has been imported, e.g. const gl = @import("gl"), you can use gl.init() to load all relevant functions.
-
All GL functions are the same as in the reference except that the
glprefix is removed. For instance:glClearbecomesgl.clear() -
All enums are the same as in the reference, except that the
GL_prefix is removed. For instance:GL_RGBAbecomesgl.RGBA
You can generate a static interface (for example, calling WASM functions) by using either .static = true in the create module config or passing --static to the standalone generator.