• Stars
    star
    523
  • Rank 84,684 (Top 2 %)
  • Language
    C++
  • License
    MIT License
  • Created almost 9 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A set of utilities for taking the pain out of Vulkan in header only modern C++

Vookoo 2.0

Vookoo is a set of dependency-free utilities to assist in the construction and updating of Vulkan graphics data structures.

To compile example codes, use the CMakeLists.txt in the root of the distribution. On unix machines (Linux/Mac OS X), the following will compile the examples:

mkdir build
cd build
cmake ..
make

Documentation:

classes

Shaders modules are easy to construct:

vku::ShaderModule vert_{device, BINARY_DIR "helloTriangle.vert.spv"};
vku::ShaderModule frag_{device, BINARY_DIR "helloTriangle.frag.spv"};

Pipelines can be built with a few lines of code compared to many hundreds in the C and C++ libraries

vku::PipelineMaker pm{(uint32_t)width, (uint32_t)height};
pm.shader(vk::ShaderStageFlagBits::eVertex, vert_);
pm.shader(vk::ShaderStageFlagBits::eFragment, frag_);
pm.vertexBinding(0, (uint32_t)sizeof(Vertex));
pm.vertexAttribute(0, 0, vk::Format::eR32G32Sfloat, (uint32_t)offsetof(Vertex, pos));
pm.vertexAttribute(1, 0, vk::Format::eR32G32B32Sfloat, (uint32_t)offsetof(Vertex, colour));

Textures are easy to construct and upload:

// Create an image, memory and view for the texture on the GPU.
vku::TextureImage2D texture{device, fw.memprops(), 2, 2, vk::Format::eR8G8B8A8Unorm};

// Create an image and memory for the texture on the CPU.
vku::TextureImage2D stagingBuffer{device, fw.memprops(), 2, 2, vk::Format::eR8G8B8A8Unorm, true};

// Copy pixels into the staging buffer
static const uint8_t pixels[] = { 0xff, 0xff, 0xff, 0xff,  0x00, 0xff, 0xff, 0xff,  0xff, 0x00, 0xff, 0xff,  0xff, 0xff, 0x00, 0xff, };
stagingBuffer.update(device, (const void*)pixels, 4);

// Copy the staging buffer to the GPU texture and set the layout.
vku::executeImmediately(device, window.commandPool(), fw.graphicsQueue(), [&](vk::CommandBuffer cb) {
  texture.copy(cb, stagingBuffer);
  texture.setLayout(cb, vk::ImageLayout::eShaderReadOnlyOptimal);
});

// Free the staging buffer.
stagingBuffer = vku::TextureImage2D{};

It is derived from the excellent projects of Sascha Willems, Alexander Overvoorde and Khronos for Vulkan-Hpp project.

[https://github.com/SaschaWillems/Vulkan]

[https://github.com/Overv/VulkanTutorial]

[https://github.com/KhronosGroup/Vulkan-Hpp]

Vookoo adds a "vku" namespace to the "vk" namespace of the C++ interface and provides user friendly interfacs for building pipelines and other Vulkan data structures.

The aim of this project is to make Vulkan programming as easy as OpenGL. Vulkan is known for immensely verbose data structures and exacting rules but this can be mitigated but providing classes to help the construction of Vulkan resources.

If you want to contribute to Vookoo, please send me some pull requests. I will post some work areas that could do with improvement.

History

Vookoo1.0 was an earlier project that did much the same thing but acted as a "Layer" on top of the C interface. Because it was duplicating much of the work of Vulkan-Hpp, we decided to replace it with the new Vookoo interface. The old one is still around if you want to use it.

Library

Currently the library consists of two header files:

vku.hpp            The library itself
vku_framework.hpp  An easy framework for running the examples

If you have an existing game engine then vku can be used with no dependencies.

If you are learning Vulkan, the framework library provides window services by way of glfw3.

The repository contains all the files needed to build the examples, but you may also use the headers stand-alone, for example with Android builds.

Examples

There are currently these examples (in order of complexity)

Simple examples
helloTriangle   Draw a triangle using vertex buffers
pushConstants   Draw a rotating triangle
texture         Draw a textured triangle

Complex examples    
teapot          Draw the Utah teapot with cube map reflections
molvoo          A molecular viewer for very large complexes

To build, you will need the Vulkan SDK from LunarG:

https://www.lunarg.com/vulkan-sdk/

Once installed, check that the GLSL compiler works:

$ glslangValidator

Building the examples on Windows:

mkdir build
cd build
cmake -G "Visual Studio 14 2015 Win64" ..\examples
VookooExamples.sln

Building the examples on Ubuntu:

sudo apt install libxinerama-dev libxcursor-dev libxrandr-dev glslang-dev glslang-tools mesa-common-dev
mkdir build
cd build
cmake ../examples
make

Please give feedback if these setting do not work for you.

More Repositories

1

andyzip

A fast and compact modern C++ (header only) zip, bzip2 and brotli library
C++
25
star
2

gilgamesh

Mesh utilities for basic meshes, marching cubes, lighting and CSG
C++
15
star
3

octet

A single module, header only C++ framework for learning OpenGL
HTML
12
star
4

unity_ply_loader

Loader for Stanford Ply files
C#
8
star
5

genetics

A boost library for genetic searches
C++
8
star
6

nrf-starter

Getting started with the Nordic nRF52840 board in rust.
Rust
6
star
7

UnityVoxels

Simple example showing how to create voxel systems using Unity3D
C#
5
star
8

range_coder

Range coder example
C++
3
star
9

parallel_algorithms

Example implementations of C++17 parallel algorithms
C++
3
star
10

unity_triangle_example

Create a single triangle in Unity
C#
2
star
11

opengex

OpenDDL/OpenGEX import/export library
C++
2
star
12

spring_mesh_example

A Unity example of a simple spring mesh
C#
2
star
13

moovoo

A molecular playground for millions of atoms.
C++
2
star
14

sudoku-solver

C++
2
star
15

boost_dna

Experiments to make a boost-style indexed DNA database
C++
1
star
16

python-server

Very simple python web server
Python
1
star
17

synthcode

compare tradtional C++ builds with single module builds.
Python
1
star
18

double_linked_list

Test to build a double linked list
C++
1
star
19

simd256

Rust
1
star
20

python_vr_triangle

A tiny (130 line) example of a triangle using openvr
Python
1
star
21

2d_marching_cubes_example

C#
1
star
22

rdata

Read and write R data in rust.
Rust
1
star
23

enigma

High performance solutions to New Scientist Enigma puzzles
C++
1
star
24

stackoverflow

Answers to stackoverflow issues
C++
1
star
25

vkcpp_test

Porting Vookoo to the NVidia vkcpp C++ interface
C++
1
star
26

forsefa

Playing with html
HTML
1
star
27

accu-rust-talk

Talk on Rust for the Oxford ACCU https://www.meetup.com/ACCU-Oxford/events/267447759/
Rust
1
star