C++ Vulkan Engine | Development Setup

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
before we can start coding we have to set up a couple of things the first thing we need is visual studio code i've put the link in the description and i trust you know how to install it then and this is a decision that you have to make i will be using the microsoft compiler from visual studio community and therefore i need to download visual studio community as well i have it already installed but i will show you my installation my installation is very simple i have clicked desktop development using c plus plus and down there i have used game development using c plus that is everything that i have selected optionally you could use llvm sd compiler i will not be covering how to set up the build system using llvm but trust me it is almost exactly the same the only difference will be in the compiler flags which we'll see later on we will also need to get the way this will work is that for every tutorial there will be a branch and if you want to skip maybe one or two tutorials you can do so i recommend that you do them all of course but if you want to skip then you will be able to clone the branch or switch to the branch and then continue from that point onward i'll explain how this goes later downloading it is very simple you just select your os and then this installer will pop up you will save the file once it has downloaded you will open the file and i will show you how i have set up my git i will not be using any of the interfaces any ui i use git from the command line and i encourage you to do so as well i will also be showing you how to do it so basically i have unticked all of these options this next page might seem confusing what it tells you is that whenever you interface with git using some special commands git will use what is called a editor to show you text and it is telling you that it will use vim as the default text editor if you don't know what vim is i encourage you to use notepad plus plus i know a bit about vim so i will keep this as default but if you don't know what vim is you should probably stick to notepad plus you have been warned this next page is kind of a troll page i let go decide to name the master branch master and not main if you don't like master then you can name it whatever you want knock yourself out right for the rest of the options with the exception of one i use the defaults simply because i don't exactly know what git is asking me to do and the default has worked for me so yeah that's what i'm sticking to and i only use some very basic git commands if you know more you're free to use whatever you want but i'll be sticking to the default options here so default option here default option here default option here and here and here yep i don't use any credential manager blah blah no this is the only exception yep nope and then install right and even if you have git already it'll manage the installation for you so there's nothing to worry about once finished uh yeah uncheck view release notes we don't care about those a quick check if it is working we press the windows button type in cmd and type git if that works if it tells you all of that stuff it should be okay if not you might have to restart your computer now once git is set up you will be using it immediately because i want you to get comfortable using git on the command line i have set up a git repository for the game we will be creating and you will need this link i've put it down in the description now we copy this link create the folder anywhere you want then go with the mouse into the path up there click and type in cmd and enter this will bring up the command line and we will now type in git clone and paste the link that we copied from the repository now since the repository is open alright we can see that it created a folder called pong from scratch this is where our game will be and we can already do the first thing that we need we create a new folder called source this is where we will put most of our header ncpp files next we need to create a build.bat file the builder bat file will be our build system and it can be difficult to create if you don't know how to do it in case you don't have it you need to enable file extensions go to the top most right tab which will probably be view for you and then enable file extensions over here if you see when i disable it the extension is gone we need the extension so we go here we create a new text file uh we call that build dot bet it's going to ask us if we want to change the extension and we're going to say yes please we now need to open our project and we can do that in two ways if you installed visual studio code and gave it the option open with code you can do that now if you haven't done so inside code you can open a folder and then select the folder that you want to open now once we have set this up we will see our source folder here the build.batch which is empty license and readme next thing we need to talk about extensions we don't need many extensions technically we only need the c plus plus extension so you go to the left here you go to extensions which is these cubes and then you type in c plus this will probably give you the first result next thing i recommend but is not required is better comments and maybe the shader language support which will be very light highlighting of glsl shaders once you've installed all the extensions the next thing you need we need to do is actually fill this build.file in order to do so we need to locate the cl compiler that ships with microsoft visual studio you know the one that we installed or you can use the llvm compiler at this point i will be looking for the cl compiler and i'll show you how to find it i also have a video on how to set up a build system like this in visual studio code i'll put that up here so if you have installed microsoft visual studio you have to find it it is most likely under c and then in programs x86 and there you have a folder that is called microsoft visual studio in there you have different versions but what we are going to do is we type in vc vars this will bring up all of these batch files windows batch files and we will be creating a 64-bit application so we will need this one when you run this it will set up a development environment that we can then use to build our application and again the linked video will have a more in-depth explanation what we will do though is we right click on the file receiver 64. bed and then open its path inside this path we press shift and then right click and then we copy the path now that we have the path copied we can go back to visual studio code and paste it this is what we will be calling and call in batch file means we will call this other batch file i will be skipping over most of the batch file stuff because i think it's not that important but i'll still mention what each line does for example the add echo off means that we will not be displaying any outputs when running this batch file unless we explicitly call echo which we will do later for example we will do echo and then building main dot dot dot right this is what we'll do now let's set up the build system what i like to do is i like to organize the build system a little bit by defining variables for example set includes and then that's links and set defines this is the typical build stuff that you see in cmake for example next we will call the cl compiler and we call the cl compiler by typing in here this will work because we called the vcvows.batch beforehand if we remove this call we will not be able to call cl the first argument that we need to specify is the error handling argument which is e h in big this will tell the program how to handle the case when the application crashes i don't know much about it i just know that it is important and that it is required if you wanna read more i've put a link in the description we also need to add those sc down here then we add the includes whoops it includes books we add the defines next we need to tell cl which cpp file we want to compile we will be compiling the source oops source main.cpp and last but not least we need to the links and that's it um oops that is mostly it we also need to fill in these but we'll do that later this is the simple build system now we can go in here and under source create a new file main.cpp whoops and then we can create a very simple program let's include i o stream and then inch main click on zero not important and what we'll do is sddc out hello world std and next we need to tell vs code that it should run the build.bet file as a task and we do that by creating a task and we create a task by defining a folder we create a new folder in the root which is called dot vs code in here we can create a new file called tasks or json this is where we will put our tasks we then start the file by opening in curly braces and oftentimes you can start these files by typing version and then autocompleting it will most likely fill out the 2.0 for you then we need to define the tasks array oops and inside the tasks array we open with curly braces again and this is where we will define our task the first thing we need to specify is the label which is just the name of the task i call this windows build don't forget to add the comma at the end there and the next thing we need to specify is the command the command will tell the task what to run this is where we will use the first variable which is dollar curly braces open workspace folder meaning this folder right here the workspace the root folder we then go ahead and call build dot but that's it this is the command that we'll do the next and last thing is we need a group and if you're lucky and you do auto completion you get this preview and you can select the default build on true and kind build and that's it if we now press ctrl shift b you see that it built main.exe over here it is ctrl shift b and it should then show you in the terminal that it builds successfully you can then press enter to close that terminal this is the first task that we need to do now we need to tell vs code how to run our program and we do that by defining a launch.json file so we go back over here inside the dot vs code folder we create a new file called launch dot json file and often times we start up with curly braces again we type inversion and autocomplete boom the next thing is called configurations what we need this is again an array and we add our first configuration which starts with curly braces the first thing we need to do is we give it a name this time it's not label but name so don't know why but yeah that's how it is i would like to call this windows launch next we tell it which program to run and we will use the same variable again here which is dollar curly braces open worked space folder close curly brace and then we call main.exe now when you are here and you don't know what to do what i like to do is hover over this and it's telling you okay so we need a type and a request i guess we do the type first and i know from experience that this is cpp vs debug i don't know what that is i just know that it you need it and that's fine by me again i don't really care about vs code i just want to type in some c plus plus code right the next thing was the request and this should automatically fill to launch which makes sense and then we also need a current working directory this will most likely default to workspace root i like to use workspace folder though i think they're the same i don't know why there's a difference that's just what i like and if i now press f5 it will run my program and print out hello world so we have now successfully set up our development environment what we now need to do is link against vulcan i've put the link to where you can download vulkan in the description i will be selecting windows and then over here we need the sdk installer so i'll be downloading this save the file now once it is finished downloading we will start the installer and i'll go through the installation process don't worry about this deprecation notice just press next this is where vulcan will be installed i'll choose the default location there's some optional stuff i will not be using any of those but i think they're very interesting and i want to use them in the future but for now i will not be using them and then we acknowledge the license and it's fine we install again we ignore the notice and we continue now if we want to check if vulcan is installed we can open the command line and type in echo percentage vulcan sdk percentage we will need this path later we could also check if vulcan is successfully running on our system to do that we locate vulcan it is under c vulcan sdk if we didn't change the default location and then you have the version here you go in here you go into bin and one of these exes is vk cube.exe we open that and we should be seeing a spinning cube back in vs code we have to close the application now because we just installed vulkan and vs code doesn't know about vulcan yet so we have to close it and then open it again once you've successfully restarted vs code we can start by including vulcan to include something we type slash capital i i forgot earlier but we need to include the source folder include works by specifying folder names then we include vulkan and how we do that is we specify the name earlier vulcan sdk in percentage and then we type slash include let me show you what that is under c in vulcan the vulcan sdk environment variable points to this folder but we need to include the source code which is under include so we have to do the slash include next thing we need is the librom vulcan which is under lib and what we want to link against is the vulcan dash1.lib file and we can do that by specifying dash link how this works is the cl compiler will look in specific paths and we have to add the vulcan path to these so we'll see a compiler knows where to look we have to specify a lib path and that lip path will be again vulcan sdk percentage slash lib and this is where we will find the vulcan dash1.lip file and that's it this is now we have successfully included and linked against vulcan using the cl compiler next we can add some defines you can add the finds by typing slash d and i like to add debug most of the time in the beginning and we might add some other stuff later but this is what we do for now let's do something more interesting than just doing io we will include vulcan slash vulcan dot h in case vs code doesn't find vulcan for you what you can do is you can press ctrl shift p which will bring up this window and then you type in preferences and then json which will open the settings.json file and in the settings.json file down here i will put this link in the description as well you can add default include path for example i have added the source folder which i think is default and i've also added the vulcan sdk include notice though that there is no percentage science in front of these but it is in curly brace that is the difference that is very important you should be able to include vulcan header then the next thing we will do is create a very simple vulcan instance and see if it actually works so we type in vk create instance over here that's how i like to do it and then we look at the stuff that we need in order to create this vk instance we need a vk instance create info okay so we go up here we type in vk instance create info boom call this instance info and i like to initialize it to zero using c plus plus is initializing now once we have the instance 38 info we can press f12 or control click to go to the definition and see what it actually wants us to specify we need a so-called structure type we need a p next we need flags application info layer count enabled layers extension count enabled extension actually we don't need most of these the most important thing that we need for now is the s type so we type in instance info dot s type and this is what will happen with every structure that you define in vulcan most of the time you will type in vk structure type instance create info oftentimes the name after structure type references the name of the structure instance create info over here instance create info looking at the structure again the next thing we need is the vk application info so we go back and specify the vk application app info and we initialize that one to zero as well then we type in app info dot and see what we need well we need an api version application version engine version application name engine name and an s type the s type is important we add in vk structure type application info this is what you always have to specify after that we go app info and check if we need anything else we can specify these things if we want to let's call this application name pong and app info engine name that pong jin or pong engine right and since i'm unsure if we actually need everything i'll just specify these and test it out if it actually works and this is what i want to emphasize in my opinion the best way to learn stuff is by just trying out and exploring your options you will fail and do a bunch of dumb mistakes but in the end in my opinion this is the best way to learn because you will then know what not to do instance info dot application info oftentimes in vulkan you will see this this p in front of the actual name that you need to specify and this signals you that you need a pointer so we will do the pointer to app info we can just check instance info real quick if we need anything else we we are not using any layers and we are not using any extensions yet so we don't need any of them and then we pass in into the vk create instance the instance create info instance info the next thing is a location callback allocator i will not be using them and i will always be specifying this as zero if you want to read up on that i highly suggest you read up in the vulcan specification on how to use them or google but i don't want to waste my time with them if i don't need them i've not been needing them yet the next thing is the vk instance we don't have apk instance yet which is the actual object that will be created when we call the vk create instance call so but i'm just going to create this on the stack right here vk instance instance right oops and we pass that in probably by pointer if it actually works yet so we pass in the p instance pointer to the instance most of the vulcan chords will return a what is called vk result return value we can then check against the vk result by doing if result is the same as vk success which is a defined success variable for vulcan we can then go ahead and do sddc out successfully created vulcan instance std end line and by the way i included the io stream back in here small disclaimer i was looking for the problem i set the variable name to enludes instead of includes which means it wouldn't find vulcan we should now be able to press ctrl shift b to compile our program which it does and then press f5 to run the program down here in the debug console we should see successfully created vulcan instance if i can spell and we created an instance and now the next time we can go ahead and build a platform layer before we go and write the renderer this will give us a basic playing round in order to continue further i'm trying to program and explain at the same time but i think it might be too slow if you'd be so kind and let me know down in the comments i'd appreciate it thank you all for watching and see you next time
Info
Channel: Cakez
Views: 274
Rating: undefined out of 5
Keywords: c++ vulkan engine, c++ vulkan, c++ pong from scratch, c++ pong game, c++ vulkan tutorial, c++ vulkan engine from scratch, c++ vulkan pong, vulkan, pong, c++ game engine, c++ vulkan game eingine, c++, c++ tutorial engine, c++ tutorial game engine, c++ guide game engine, c++ guide vulkan engine, vulkan guide, vulkan game engine, vk game eingine, vk guide game engine, vk tutorial game engine, vulkan tutorial game engine, vulkan pong, game engine pong, build a game engine
Id: tRQ3zqCiKdQ
Channel Id: undefined
Length: 20min 55sec (1255 seconds)
Published: Sun Oct 31 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.