Vulkan bindings for the C3 programming language with idiomatic C3 error handling and builder patterns for easy Vulkan development.
- Complete Vulkan API Coverage - Bindings for Vulkan API versions 1.0 through 1.4
- Idiomatic C3 Error Handling - Vulkan commands use C3's error handling mechanisms
- Builder Pattern - Auto-generated builder pattern for easy Vulkan struct creation
- Cross-Platform - Supports Windows, Linux (Wayland/X11), and macOS
- Working Example - Includes a complete 3D cube example to get you started
Before using this library, you need:
- C3 Compiler - Install the latest version of the C3 compiler
- Vulkan SDK - Download and install the Vulkan SDK for your platform
# Linux
c3c run cube
# Windows
c3c run cube-win
# macOS (adjust path as needed)
c3c run cube -z -rpath -z /Users/yourusername/VulkanSDK/macOS/lib-
Install Vulkan SDK:
# Ubuntu/Debian sudo apt install vulkan-tools vulkan-validationlayers-dev spirv-tools # Or download from LunarG website and follow their instructions
-
Choose Display Server (Wayland or X11): Edit
project.jsonand set the appropriate feature:"features": ["WAYLAND"] // For Wayland // or "features": ["X11"] // For X11
-
Install Vulkan SDK: Download from LunarG Vulkan SDK
-
Add Vulkan to PATH: Ensure
VULKAN_SDKenvironment variable is set -
Cross-compilation from Linux: If developing on Linux but targeting Windows, the
cube-wintarget includes the necessary Windows SDK configuration.
-
Install C3: Follow the macOS installation guide
-
Install Vulkan SDK: Download Vulkan SDK for macOS
-
Run the example with the Vulkan library path:
# Replace /path/to/VulkanSDK with your actual SDK path c3c run cube -z -rpath -z /Users/yourusername/VulkanSDK/macOS/lib
Controls:
- Mouse: Click and drag to rotate the camera
- Scroll: Zoom in/out
-
Build the library file:
Download the prebuilt library from here
Or build manually.
c3c build zip --trust=full
This creates
vulkan.c3lin the project root. -
Copy
vulkan.c3lto your project's library directory (e.g.,./libs/) -
Update your
project.json:{ "dependency-search-paths": ["./libs"], "dependencies": ["vulkan"] } -
Use in your code:
import vk; fn void main() { // Create Vulkan instance ApplicationInfo info = { .pApplicationName = "TEST", .pEngineName = "Super 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) .setFlags(env::os_is_darwin() ? vk::INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR : 0) .setEnabledExtensionNames(extensions.array_view()); } }
If you want to regenerate the Vulkan bindings from the official XML specification:
- Run the build script:
sh build.sh
This project is licensed under the terms found in the LICENSE file.
Contributions are welcome! Feel free to open issues or submit pull requests.