This is an example for how to use mach-glfw and zig-opengl together to create a modern OpenGL 4.1 (latest version supported on macOS) window.
Cloning submodules is required, so use --recursive
:
git clone --recursive https://github.com/hexops/mach-glfw-opengl-example
cd mach-glfw-opengl-example/
zig build run
This example only clears the screen to a purple color. It doesn't show how to get e.g. triangles onto the screen; you'll need to look at other OpenGL examples for that as a next step. We're happy to accept a PR for this.
zig-opengl provides a binding generator which uses dotnet
to generate pure-Zig OpenGL bindings. We generate and commit them to this repository for simplicity:
cd libs/zig-opengl/
mkdir exports/
dotnet run -- OpenGL-Registry/xml/gl.xml ../gl.zig GL_VERSION_4_1
You can join the Mach discord for help if this example doesn't work. Also consider joining the Zig discord's #gamedev
channel.