- Zig 99.8%
- GLSL 0.2%
| examples | make default font global | |
| src | minor | |
| build.zig | - update for zig 0.16 (nightly) | |
| build.zig.zon | - update for zig 0.16 (nightly) | |
| hello.jpg | init | |
| LICENSE | init | |
| NotoSans-Regular.ttf | init | |
| README.md | readme update | |
| zeppelin.jpg | uncapped fps screenshot | |
Zeppelin
Zeppelin is a cross-platform 2D graphics and window library in pure zig*. It features:
- Vulkan-based vector graphics
- window handling
- input handling (including an xkb parser on wayland!)
- built-in text rendering using either Andrew's TrueType or harfbuzz
- clipboard support
While zeppelin was written to enable pure-Zig GUI development, it is also suitable for:
- 2D games
- 2D off-screen rendering
- as a convenient but very incomplete Vulkan abstraction layer
Zeppelin tries to be as self-contained as possible to keep complexity low and to prepare for a future free from C and C++. Therefore, it does not have any hard dependency on C/C++ libraries besides libc. No sdl, glfw, libwayland, libxkbcommon, or freetype. At the same time, this is also the reason why zeppelin can't just give you an OpenGL or Vulkan graphics context, as both EGL and Vulkan depend on libwayland.
Currently, Linux (Wayland) and Windows are supported. Android support is planned. MacOS/iOS support is not planned at the moment but contributions in that direction are welcome!
Zeppelin is in an alpha stage but with a decent feature set. API will change.
*Libc is currently required to load a vulkan driver; optionally depends on harfbuzz for non-latin text shaping.
Try the nanovg demo in zeppelin:
git clone https://codeberg.org/ssmid/zeppelin
cd zeppelin
zig build demo
Example
Drawing a triangle:
pubfnmain()!void{varcontext=tryzeppelin.Zeppelin.create("hello",1,false,allocator);defercontext.destroy();constrenderer=trycontext.createWindowRenderer(800,600,"Hello",null,null);deferrenderer.destroy();constwindow=renderer.getWindow();outer:while(true){constevents=trywindow.getEvents();for(events)|*event|{switch(event.*){.window_close=>break:outer,else=>{},}}constready=tryrenderer.nextFrame();if(!ready)continue;tryrenderer.moveTo(400,100);tryrenderer.lineTo(600,400);tryrenderer.lineTo(200,400);tryrenderer.close();tryrenderer.fill(&zeppelin.color(255,0,0,255),null);tryrenderer.text("Hello, triangle!",400,450,.{.horizontal=.center},null,48);tryrenderer.fill(&zeppelin.color(230,230,230,255),null);_=tryrenderer.render();}}
See the full example at https://codeberg.org/ssmid/zeppelin/src/branch/main/examples/hello.zig
Usage
Just like any other zig library:
zig fetch --save https://codeberg.org/ssmid/zeppelin/archive/0.3.0.tar.gz
Releases will always target the latest zig version. If you target zig nightly builds, please try the main branch. https://codeberg.org/ssmid/zeppelin/archive/{commit-or-tag}.tar.gz
Documentation: https://ssmid.de/zeppelin/doc/
Roadmap
- clipboard
- DPI scaling
- simple software renderer (as fallback)
- drag and drop
- touch input
- android support
- packager
- api integration
- soft keyboard / input method support
- better anti-aliasing
Contributing
Build some cool stuff and show it to me!
Bug reports, feature requests, and pull requests are welcome as well, just make sure to check with me before you start any serious effort.