Skip to content

MidlightStudio/zig-opengl-bindings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zig OpenGL Bindings

An OpenGL bindings generator for Zig. Includes dynamically loading.

Usage: build.zig

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"));

Usage: Standalone

Building

Building the standalone binary is as simple as:

zig build -Doptimize=ReleaseFast

You can then run the generator with

./zig-out/bin/opengl-bindings gles2 GL_ES_VERSION_3_0 output.zig

Usage: Loading

Once 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 gl prefix is removed. For instance: glClear becomes gl.clear()

  • All enums are the same as in the reference, except that the GL_ prefix is removed. For instance: GL_RGBA becomes gl.RGBA

Static Interface

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages