Are there any good windowing libraries?

I tried using GLFW with Zig’s C interop. However, I couldn’t figure that out after several hours.

All of the GLFW bindings I found are designed for Zig 0.14, however I am using 0.15 currently.

Are there any good windowing libraries (or bindings) for zig?

Shameless plug, but you could give sokol a try, the ‘GLFW equivalent’ is sokol.app. It’s originally a C library, but with somewhat ‘idiomatic bindings’.

The C project is here:

Bindings with Zig examples are here:

…and a simple Dear ImGui example:

You’ll need the very latest nightly, which has a package-fetch problem on Windows. On macOS or Linux you should be fine.

PS: expect some limitations compared to GLFW or SDL though, mainly that only single-window-apps are supported and instead of an “own the game loop” model there are frame- and event-callbacks. In exchange you get better web support and builtin support for D3D11, Metal, WebGL and WebGPU. I wrote sokol-app originally to get some sort of simple window- and input-support at all across all platforms supported by sokol-gfx without having to pull in a GLFW or SDL dependency, not really as a fully-featured GLFW replacement :slight_smile:

5 Likes

Sokol looks awesome, however I am unfortunately stuck on the affected Windows at the moment.

Are there any plans to fix that soon?

What do you actually want to do with the window?
Do you want to use some particular graphics api or not?
Any specific criteria?

I think using 0.14 would give you more options, because it is likely they target either 0.14 or 0.14.1 or whatever is the latest mach nominated version.

At least I haven’t seen many graphics related projects that track zig master.

1 Like

@castholm’s project states in the readme that it supports both 0.14.1 and 0.15.0-dev (master):

1 Like

Just vulkan. All I actually need is the windowing part.

SDL3 zig port looks awesome. I’ll check that out.

1 Like

Maybe you could do something similar to the example from https://github.com/Snektron/vulkan-zig/tree/master?tab=readme-ov-file#example it seems it uses GLFW in a relatively minimal way, but it uses a system dependency.

1 Like