- Update gl.xml (if necessary)
- Open loader_gen.py
- Line 149, change
API
to the one you want (gl, gles). - Line 150, change
VERSION
to the one you want - Run the python file.
If everything's ok, there is a file called "gl.zig" that you can use.
The whole gl.zig file is a structure.
const GL = @import("./gl.zig");
// not adviced as this structure holds all of the pointers to the OpenGL
// commands.
var gl = GL {};
// loadProc must has the signature `fn([:0]const u8) ?*anyopaque`.
try gl.load(loadProc);
// at this point, all of the OpenGL functions are loaded and can be called.
gl.clear(GL.COLOR_BUFFER_BIT);
The OpenGL functions are renamed as such:
- The
gl
prefix is stripped. - The first letter is not capitalised
The OpenGL enums are renamed as such:
- The
GL_
prefix is stripped.
The OpenGL types are mapped to their Zig equivalent (ie, GLenum
becomes u32
, GLfloat
becomes f32
) except :
GLsync
becomesGL.Sync
(GL
being the imported structure) ;GLDEBUGPROC
becomesGL.DebugFn
.