Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jpbruyere/vkhelpers
Vulkan c helper library
https://github.com/jpbruyere/vkhelpers
c helper multiplatform vulkan
Last synced: 19 days ago
JSON representation
Vulkan c helper library
- Host: GitHub
- URL: https://github.com/jpbruyere/vkhelpers
- Owner: jpbruyere
- License: mit
- Created: 2017-12-08T14:14:09.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-02-04T12:04:39.000Z (11 months ago)
- Last Synced: 2024-04-14T05:33:00.757Z (9 months ago)
- Topics: c, helper, multiplatform, vulkan
- Language: C++
- Size: 449 KB
- Stars: 30
- Watchers: 6
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Vulkan Helpers
Small personal helper library for [Vulkan](https://www.khronos.org/vulkan/) usage in **c**.
Simplify several common tasks, as image or buffers handling, swapchain initialization, etc.**vkh** is used by [vkvg] internally and also to speed up vulkan context creation in samples.
### Building from source
```bash
git clone https://github.com/jpbruyere/vkhelpers.git
cd vkhelpers
mkdir build
cd build
cmake ..
make && make install
```### Adding vkh to your CMake project
- clone vkh as a subdirectory of your root dir.
- in your main CMakeFile, add `add_subdirectory (vkhelpers)`
- add to your **TARGET_INCLUDE_DIRECTORIES** `${CMAKE_CURRENT_SOURCE_DIR}/vkhelpers/include` and if you want to bypass opaque pointers and be able to address
fields of internal structures, add also `${CMAKE_CURRENT_SOURCE_DIR}/vkhelpers/src`.
- to link vkh staticaly, add to **TARGET_LINK_LIBRARIES** `vkh_static` or `vkh_shared` to link it as a shared library.### Quick howto:
##### Create instance
```c
#include "vkh.h"
#include "vkh_phyinfo.h"void init_vulkan () {
const char* layers [] = {"VK_LAYER_KHRONOS_validation"};
const char* exts [] = {"VK_EXT_debug_utils"};
VkhApp app = vkh_app_create ("appname", 1, layers, 1, exts);
```
##### Select physical device**VkhPhyInfo** is an helper structure that will store common usefull physical device informations, queues flags, memory properties in a single call for all the devices present on the machine.
```c
VkhPhyInfo* phys = vkh_app_get_phyinfos (e->app, &phyCount, surf);
```
Once you have an array of VkhPhyInfo's, you have several functions to inspect available devices:
```c
for (uint i=0; iapp, pi, &device_info);
```
##### The Presenter
VkhPresenter will help getting rapidly something on screen, it handles the swapchain.
```c
VkhPresenter present = vkh_presenter_create (dev, pi->pQueue, surf, width, height, VK_FORMAT_B8G8R8A8_UNORM, VK_PRESENT_MODE_MAILBOX_KHR);
//create a blitting command buffer per swapchain images with
vkh_presenter_build_blit_cmd (present, vkvg_surface_get_vk_image(surf), width, height);
while (running) {
if (!vkh_presenter_draw (present))
//on draw failed, swapchain is automatically rebuilt
vkh_presenter_build_blit_cmd (present, vkvg_surface_get_vk_image(surf), width, height);
}
```
##### Creating Images
TODO
##### Creating Buffers
TODO