Vulkan bindings for C3, auto-generated from the official Vulkan XML specification. Covers Vulkan 1.0 through 1.4 with all platform-compatible extensions included.
- Idiomatic C3 error handling — Vulkan error codes map to C3 faults
- Builder pattern — auto-generated
.set*()and.build()methods for Vulkan structs - Cross-platform — Windows, Linux (X11/Wayland), and macOS
vk/ # Generated + hand-written bindings (this is the library)
vk.c3 # Types, enums, structs, unions
commands.c3 # Function declarations and extension loading
builders.c3 # Auto-generated builder/setter methods
extra.c3 # Hand-written type aliases (platform types, function pointers)
helpers.c3 # Convenience wrappers (swapchain, device queries, etc.)
buffer.c3 # Memory allocator and buffer helpers
parser/ # Bindings generator (reads vk.xml, writes vk/*.c3)
build.c3 # Main generator logic
types.c3 # XML parsing types
examples/
cube/ # 3D rotating cube with camera controls
- C3 compiler (latest version)
- Vulkan drivers installed for your GPU
Linux:
c3c run cubeWindows:
c3c run cube-winmacOS (needs Vulkan SDK rpath):
c3c run cube -z -rpath -z /path/to/VulkanSDK/macOS/libLinux — install Vulkan packages for your distro:
# Ubuntu/Debian
sudo apt install libvulkan-dev vulkan-tools vulkan-validationlayers-dev spirv-tools
# Fedora
sudo dnf install vulkan-loader-devel vulkan-tools vulkan-validation-layers-devel spirv-tools
# Arch
sudo pacman -S vulkan-icd-loader vulkan-tools vulkan-validation-layers spirv-toolsWindows — download and install the Vulkan SDK. Make sure VULKAN_SDK is set. The cube-win target includes Windows SDK configuration for cross-compilation from Linux.
macOS — download the Vulkan SDK for macOS and pass the library path when building (see above).
Download vulkan.c3l from releases, place it in your project (e.g. ./libs/), and add it to your project.json:
{
"dependency-search-paths": ["./libs"],
"dependencies": ["vulkan"],
"linked-libraries": ["vulkan"]
}c3c build zip --trust=fullThis creates vulkan.c3l in the project root.
import vk;
fn void! main() {
ApplicationInfo info = {
.pApplicationName = "My App",
.pEngineName = "My Engine",
.applicationVersion = vk::@makeApiVersion(0, 1, 0, 0),
.engineVersion = vk::@makeApiVersion(0, 1, 0, 0),
.apiVersion = vk::@makeApiVersion(0, 1, 3, 0)
};
InstanceCreateInfo instanceInfo = vk::instanceCreateInfo()
.setApplicationInfo(&info)
.setEnabledExtensionNames(extensions.array_view());
vk::Instance instance;
vk::createInstance(&instanceInfo, null, &instance)!;
}The builder pattern lets you chain .set*() calls, then call .build() on create-info structs:
vk::Pipeline pipeline = vk::graphicsPipelineCreateInfo()
.setStages(shader_stages)
.setLayout(pipeline_layout)
.setRenderPass(render_pass)
.build(device)!;To regenerate the bindings from the latest Vulkan XML specification:
sh build.shThis downloads vk.xml from the Khronos repository and runs the parser. All extensions compatible with supported platforms (Win32, X11, XCB, Wayland, macOS/Metal, iOS) are included. Extensions referencing undefined types are automatically skipped.
- Window library (c3w) — windowing dependency used by the examples
- Example game — a larger project using these bindings
- C3 documentation
- Vulkan Tutorial
- Vulkan Specification
See LICENSE.