Vulkan2D
2D renderer written in C using Vulkan and SDL2
|
Vulkan2D is a 2D renderer using Vulkan and SDL2 primarily for C games. VK2D aims for an extremely simple API, requiring no Vulkan experience to use. Astro and more recently Sea of Clouds internally use Vulkan2D for rendering. My other projects Bedlam, Spacelink, and Peace & Liberty also used Vulkan2D, although a much older version of it. Check out the quick-start guide.
VK2D/VulkanInterface.h
Check out the documentation website.
There are two parts to building it with your project: you must build VK2D and also VMA since VK2D needs VMA to function. You'll likely need to do something like this in CMake:
Vulkan2D also requires the following external dependencies:
SDL2, 2.0.6+ Vulkan 1.1+ C11 + C standard library C++17 (VMA uses C++17)
By default the program automatically crashes on fatal errors, but you may specify Vulkan2D to not do that and check for errors on your own. The following example uses default settings meaning that if there is an error in VK2D, it will print the status to vk2derror.txt
and quit.
If you don't want VK2D to crash on errors you may specify that in the struct VK2DStartupOptions
passed to vk2dRendererInit
and check for errors yourself with vk2dStatus
, vk2dStatusMessage
, and vk2dStatusFatal
. Any VK2D function can raise fatal errors but unless you pass bad pointers to VK2D functions, they will not crash if there is a fatal error and will instead simply do nothing.
All examples are tested to work on Windows and Ubuntu. The CMakeLists.txt
at the root directory will generate build systems for each example. Be sure to compile the test shader before running the examples/main/
example with:
glslc assets/test.frag -o assets/test.frag.spv glslc assets/test.vert -o assets/test.vert.spv
If you don't trust binary blobs you may also compile the binary shader blobs with the command
genblobs.py colour.vert colour.frag instanced.vert instanced.frag model.vert model.frag shadows.vert shadows.frag spritebatch.comp
run from the shaders/
folder (requires Python).