All Projects → mackron → Vkbind

mackron / Vkbind

Single file Vulkan API loader.

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Vkbind

Glbind
Single file OpenGL API loader.
Stars: ✭ 23 (-79.09%)
Mutual labels:  public-domain, win32, binding, loader
Mgs Machinery
Unity plugin for binding machinery joint in scene.
Stars: ✭ 164 (+49.09%)
Mutual labels:  binding, loader
Runpe In Memory
Run a Exe File (PE Module) in memory (like an Application Loader)
Stars: ✭ 249 (+126.36%)
Mutual labels:  win32, loader
vkel
Simple Dynamic Vulkan Extension Loader
Stars: ✭ 39 (-64.55%)
Mutual labels:  vulkan, loader
luacc
Lua Code Combine
Stars: ✭ 36 (-67.27%)
Mutual labels:  binding, loader
Vulkandemos
Some simple vulkan examples.
Stars: ✭ 413 (+275.45%)
Mutual labels:  vulkan, examples
Flextgl
OpenGL and Vulkan header and loader generator.
Stars: ✭ 180 (+63.64%)
Mutual labels:  vulkan, loader
gnuplot-examples
GNUPlot Examples
Stars: ✭ 50 (-54.55%)
Mutual labels:  examples, public-domain
eseed-window
A minimal cross-platform C++17 window management library for rendering (deprecated)
Stars: ✭ 18 (-83.64%)
Mutual labels:  vulkan, win32
Example Ios Apps
 A curated list of Open Source example iOS apps developed in Swift. An amazing list for people who are beginners and learning ios development and for ios developers who need any example app or feature.
Stars: ✭ 461 (+319.09%)
Mutual labels:  apple, examples
Awloader
AWLoader is a UI Component that allows you to integrate loader that fits your needs within your app.
Stars: ✭ 11 (-90%)
Mutual labels:  apple, loader
Net Core Push Notifications
Lightweight .NET Core Push Notifications for Android and iOS
Stars: ✭ 105 (-4.55%)
Mutual labels:  apple
Real World Ruby Apps
Real World Ruby apps and their open source codebases for developers to learn from
Stars: ✭ 107 (-2.73%)
Mutual labels:  examples
Raytracedshadows
This demo implements BVH construction and GPU traversal for rendering hard shadows.
Stars: ✭ 107 (-2.73%)
Mutual labels:  vulkan
Cupertinojwt
Parse Apple's .p8 private key file and sign JWT with ES256, without third-party dependencies.
Stars: ✭ 107 (-2.73%)
Mutual labels:  apple
Samples
Community driven repository for Dapr samples
Stars: ✭ 104 (-5.45%)
Mutual labels:  binding
Powershell Phpmanager
A PowerShell module to install/update PHP, PHP extensions and Composer on Windows
Stars: ✭ 108 (-1.82%)
Mutual labels:  win32
Go Examples
examples written using golang third party packages.
Stars: ✭ 106 (-3.64%)
Mutual labels:  examples
Vulkan Samples
One stop solution for all Vulkan samples
Stars: ✭ 2,009 (+1726.36%)
Mutual labels:  vulkan
Albookcode
Modern Auto Layout Book Sample Code And Solutions
Stars: ✭ 106 (-3.64%)
Mutual labels:  apple

A single file Vulkan header and API loader.

discord twitter

vkbind includes a full implementation of the Vulkan headers (auto-generated from the Vulkan spec) so there's no need for the offical headers or SDK. Unlike the official headers, the platform-specific sections are all contained within the same file.

Usage

For platforms that statically expose all Vulkan APIs you can use vkbind like so:

#define VKBIND_IMPLEMENTATION
#include "vkbind.h"

int main()
{
    VkResult result = vkbInit(NULL);
    if (result != VK_SUCCESS) {
        printf("Failed to initialize vkbind.");
        return -1;
    }

    // Do stuff here.

    vkbUninit();
    return 0;
}

For those platforms that do not statically expose all Vulkan APIs, you should do something like this:

#define VKBIND_IMPLEMENTATION
#include "vkbind.h"

int main()
{
    VkbAPI api;
    VkResult result = vkbInit(&api);
    if (result != VK_SUCCESS) {
        printf("Failed to initialize vkbind.");
        return -1;
    }
    
    // ... Create your Vulkan instance here (vkCreateInstance) ...

    result = vkbInitInstanceAPI(instance, &api);
    if (result != VK_SUCCESS) {
        printf("Failed to initialize instance API.");
        return -2;
    }

    result = vkbBindAPI(&api);  // <-- Optional. Can call APIs directly like api.vkDestroyInstance().
    if (result != VK_SUCCESS) {
        printf("Failed to bind instance API.");
        return -3;
    }

    // Do stuff here.

    vkbUninit();
    return 0;
}

The code above uses the VkbAPI structure which contains function pointers to all Vulkan APIs. The idea is that you first initialize with vkbInit(), then call vkbInitInstanceAPI() after you've created your Vulkan instance. The VkbAPI object will be filled with usable function pointers at this point (so long as they're supported by the platform). In this example, the instance APIs are bound to global scope using vkbBindAPI(), however if you have multiple instances running at the same time, you should instead invoke the functions directly from the VkbAPI object.

You can also initialize the VkbAPI object from a Vulkan device. This is optional, and is intended as an optimization to avoid the cost of internal dispatching. To use this, you first initialize your VkbAPI object with vkbInitializeInstanceAPI(), then call vkbInitializeDeviceAPI(), passing in the same VkbAPI object.

VkbAPI api;
vkbInitInstanceAPI(instance, &api);
vkbInitDeviceAPI(device, &api);
vkbBindAPI(&api);

Examples

You can find some general Vulkan examples in the "examples" folder. The first example, 01_Fundamentals, is completely flat and self contained in a single code file. This is unlike most of the other popular example projects out there which are full of abstractions which make things too hard to follow. It covers most (all?) of the fundamentals any real Vulkan program is going to need, and tries to explain how things like vertex layouts and descriptor sets interact with shaders which I think is something other examples seem to overlook.

For practicality, future examples will not be entirely flat, but should still be significantly better than other popular examples out there in terms of readability.

Note that shaders are pre-compiled with glslangValidator (GLSL to SPIR-V compiler) and embedded into a source file for each example. This is just to avoid the need to worry about file IO for shaders and to focus on Vulkan itself.

License

Public domain or MIT-0 (No Attribution). Choose whichever you prefer.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].