maierfelix / node-vulkan
- среда, 3 октября 2018 г. в 00:19:26
C++
Vulkan bindings for JavaScript
This is a Vulkan API for node.js.
The bindings are machine generated and provide an API to interact from JavaScript with the low-level interface of Vulkan. The API of this project strives to be as close as possible to Vulkan's original API.
Note: This is an early experiment, use with honor!
generator
: code for binding generationgenerated
: the generated binding codeexamples
: contains a triangle and cube demolib
: required third party libsMake sure you have either Visual Studio >= 15 installed or use
npm install --global --production windows-build-tools
Install the Vulkan SDK from here
Clone this repo
git clone git@github.com:maierfelix/node-vulkan.git
Install dependencies
npm install
npm run [script] [flag] [value]
[-vkversion] [version]: The vulkan version to generate bindings for
You can specify a version to generate bindings for like this:
npm run generate -vkversion=1.1.82
generate/specifications/{vkversion}.xml
generated/{vkversion}/
You can build the generated bindings like this:
npm run build -vkversion=1.1.82
The compiled bindings can then be found in generated/{vkversion}/build
The API gives you some sugar to write things quicker, but still gives you the option to write everything explicitly
sType
members get auto-filled, but you can still set them yourself
let appInfo = new VkApplicationInfo();
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
Becomes:
let appInfo = new VkApplicationInfo(); // sType auto-filled
Instead of:
let offset = new VkOffset2D();
offset.x = 0;
offset.y = 0;
let extent = new VkExtent2D();
extent.width = 640; extent.height = 480;
let renderArea = new VkRect2D();
renderArea.offset = offset;
renderArea.extent = extent;
You can write:
let renderArea = new VkRect2D({
offset: new VkOffset2D({ x: 0, y: 0 }),
extent: new VkExtent2D({ width: 640, height: 480 })
});