Welcome. In this tutorial we will be learning about Vulkan and specifically all the steps and code we need to render a triangle to the screen.
First things first, let me just warn you that this is not a beginners tutorial to rendering APIs. I assume you have some experience with something like OpenGL or DirectX and you are here just to get to know the particularities of Vulkan. My main goal with this "tutorial" is to get to a complete but minimal C program running a graphical pipeline using Vulkan on windows (linux also, if I get the time. If you are interested in the ongoing, but working port of this code to linux/XCB you can check this commit 15914e3 ). So, let’s start.
I will be posting all the code on this page. I will do it progressively, but you will be able to see every piece of code going into the tutorial. If you want to follow along and compiling the code on your side you can clone the following git repo:
git clone https://bitbucket.org/jose_henriques/vulkan_tutorial.git
I have successfully compiled and ran every commit on Windows 7 and 10 running Visual Studio 2013. Because I don’t use the IDE (I only use the compiler), I provide a build.bat that you should be able to use to compile the code. You do need to have the cl compiler on your path before you can call the build.bat from your console. [you need to find and run the right vcvars*.bat for your setup. For the setup I’m using you can find at "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/x86_amd64/vcvarsx86_amd64.bat"]
For each step I will point out the commit that you can checkout to compile and play around with on your side. For example, to get the start commit with the platform skeleton code, you can do the following:
git checkout 39534dc
Now, as important as our goals, here are the things that I will not be trying to accomplish with this tutorial. First, I will not be creating a "framework" that you can take and start coding your next engine… I will indeed not even try to create functions for code that repeats itself some times. I see some value on having all the code that is involved on a process directly, instead of having to navigate a couple indirections to get the full picture, specially on a tutorial.This tutorial will finish once we get a triangle on the screen with a graphics pipeline with a vertex and fragment shader running. I might do some other tutorials for other topics, but this is not it!
You can use this code free of charge if that will bring you any value… I think this code is only good for learning the API, but if you end up using it, credits are welcome.