This is the first series on Game Engine programming that is easy to follow, elaborate, and practical. This can serve as learning material, as well as a base for one's own engine, because of the implemetation of common and practical tools such as GLFW, Vulkan. Please keep on updating
Summer starts soon, so I'm thinking of watching this series seriously. The best part about it so far in my opinion is that it seems to be all laid out and planned (4:15 - "Which we'll cover in around episode 10"!) One other thing I've just thought about is that the code hints + documentation are convenient to pause and read about as I watch (as one being unfamiliar with C++)
The really cool thing about this Brendan is that as a Mac user (and I love my mac) I was so frustrated to find that opengl is no longer an option due to Apple not supporting it. I have been looking into getting a windows pc to get into 3D stuff and then I find this Vulkan (that i hadn't heard of) and that it runs in Xcode. Perfect, thanks so much.
I think I'm finally ready to start learning Vulkan. Thanks for making this series! I just finished this video and I'm excited to continue, really thank you for making these videos. It's an invaluable resource!
ya vulkan/computer graphics in general is a complicated beast. It's definitely an industry that has advanced as quickly as it has due to passion. Takes a lot of patience and trial and error to learn. I've been learning for over a decade, and still have much to learn! Hopefully this series can be a helpful part on your journey :)
@@BrendanGalea man this month i kept jumping from a game engine to another but now i feel like most game engines at this time use opengl which is old and i been trying to make a complex game in both godot and unity but bending the engine around to fit my needs felt hard lol ig makin a game engine is the way to go good luck bro i am excited to see what both of us can come up with in the future
@@BrendanGalea i see you made some changes in the reference code. at first i got 118 errors. among which "FirstApp" is not a member of lve, which you put in there. it should be "first_app". changed that... the error is gone. I really hope you check errrors before posting the vid. otherwise this is going to be another completely useless tutorial, because it no worky.
@@avatharbehemoth - I'm not sure to which part you are referring to, do you have a timestamp? first_app is the file name, but the classes name is FirstApp I do run all the code on windows (starting after tutorial 5), linux and macos before posting so it should be mostly free of errors, but any mistakes that do come up after posting I will make a pinned comment :)
@@BrendanGalea So at the end of the video when i tried to compile i had 118 errors. Some were mine where i forgot a "}", ")" a ";" or something. Others were far more challenging. After i fixed those i had 5 errors left I ended up changing the class name to "first_app" in first_app.cpp, hpp and main. in order to get it to work. Had some serious documentation to read, errors to google and the last error was probably the most challenging. Unhandled exception at 0x00051526 Access violation reading location 0x00000004/return glfwwindowshouldclose(window) unhandled exception. Since the window was a null pointer. and you wanted to return it as a boolean.
@@BrendanGalea that’s cool I thought viscose was just c# on Mac. Will check that out then. Suppose you just follow visual studio to set up project. Will give it a go
Definitely need to rewatch the videos again after following along the first time. Struggling to keep up with the typing and also listen to the explanations lmao
Sorry! When I first started this I felt uncomfortable recommending a particular setup. But I should probably get around to creating a video at least showing how to set things up as I have them
Thank you for this tutorial Brendan. I'm following this on Windows. In this video, when you ran the code before implementing run(), and nothing happened, something felt unintuitive about that, because we already wrote the code to initialise the window, so I was expecting the window to open. Well I tried running the code without the run() implementation, and found that for me, the window opens for a split second then closes. Here's my theory on this, please anyone correct me if I am wrong: I guess this is because the default nature of the GLFWwindow is to destruct after it has gone through a single polling cycle. Question: Does this mean we are recreating the window at a very fast rate to give the illusion of a single steady window? It makes me wonder about how the game loop is integrated within an already running while loop too. Thank you!
thanks for the tutorial, straight to the facts and no fancy writing, like KISS principle. Btw why are you using another class to initialize the first class constructor with static variables inside the second class? Would be simpler to just initialize the values inside the first class itself for the window
0:53 I got the example program running on my computer on Linux and the empty window shows up. However, instead of having a solid gray background color, it "screenshots" whatever was beneath the window before it was created, as if the program had frozen. Was that supposed to happen?
I've been working on the code in this tutorial for a couple days now, pretty new to c++. I have a few questions. 1. why does GLFWwindow* window; not need to be initialized? 2. in first_app.hpp why does LveWindow lveWindow (WIDTH, HEIGHT, "Hello Vulkan!" }; use {} instead of ()? Thanks for all the work you put in the series man, I'm a bit of a dumb ass though.
1. We initialize window in the constructor, so it doesn't need to be initialized immediately in the header. 2. You could used (), {} initialization is just an alternative way to initialize things. For more details: www.learncpp.com/cpp-tutorial/variable-assignment-and-initialization/
GLFW and SDL libraries, any others, GLFW does it only work on computers, not phones, tablets, consoles, or any other devices? What about SDL or alternatives to use if I want to make sure my app/game can function on ANY device?
This is a great set of tutorials, thanks Brendan! I've just completed this tutorial 01 and instead of a blank window mine is filled with a copy of what was underneath it when the window was created, as if it took a screenshot. Any idea what could be the cause?
Thanks! And I don’t think that is something to worry about. Might just be how your OS defaults the pixels and we haven’t cleared or drawn over them at this stage yet.
Awesome video, when I try running the project the background of the window looks like a screenshot of the upper right of my screen, though I suspect thats a cinnamon desktop bug haha
ya i wouldn't worry about that at this point. It's just a quirk of how different operating systems handle the initial value for the window at this point. Once we start rendering it won't be an issue.
How did you set it up for Visual Studio Code? I see that the Vulkan Docs use Microsoft Visual Studio. It is probably more complicated in VS Code than VS I'm guessing. I was just curious because I use VS Code quite a lot. Thanks for the videos.
I’ve been using Linux and macOS. It should be possible to set things up on vsCode for windows, maybe with using cmake. Just getting the build settings right might take some time. It’s something I’ve been meaning to do
I've been meaning to set this up with VSCode on Windows. You just have to modify some json environment files in VsCode to let it know what include paths to add in, but otherwise, it should work just the same after pressing "Build" If I find any good tutorials, I'll post them here!
@@rogerwinright2290 If you find anything please share, I've been doing the series using VS Community because I don't know how to include the libraries in VS Code.
Dumb question: I see that there is a lot of 3D stuff in the later videos, but could I also learn all the things necessary to use the knowledge for making a 2D stuff? I guess 2D is just 3D but without the Z coordinate, but I'm new to all of this. I will still go through all videos as I am interested in the process anyway, if it will be useful or not for my end goal :p
Yup! Rendering 2D will work just fine. For the most part you’d use all the same 3D stuff except you’d probably use an orthographic projection matrix instead of a perspective projection. I do plan on covering some 2D topics in the future as well such as sprite rendering.
I have a question about the construction of your logical device. Why, when describing VkDeviceQueueCreatInfo, you also describe VkDeviceCreatInfo, the feeling is that you are creating two logical devices.
what's the timestamp for the part you are referring to? Only one logical device is being created. A device queue and device are different things. One device can have multiple device queues.
Just a configuration file that specifies the filepaths to locate libraries, object files, etc. the reason I use a .env file is that I don’t commit it to the GitHub so that when developing on different machines they can each specify their own filepaths. .env is just a common name for a file that is used to specify local environment information specific to the machine running the code and not meant to be shared. The .env_example is just used as a template for the env file to remember what the variable names are
Very cool. Confused about a couple of things: Why use a destructor for the window, if we don't have a window the application should surely close (and then we just let the OS clean up right?) also why use a std::string to pass the window title when glfw expects a char* (so you're converting char* into string then back into char* again with .c_str() ..) It's just that I see these practices shown in every c++ tutorial on youtube and they make no sense to me at all.
I think the reason most c++ tutorials use strings because they tend to be easier to work worth, (string concatenation, getting length, etc.) and whenever a c-style char * is required, they can easily be converted by using the c_str() function. The destructor for the window is just good programming practices. Even though when the window is closed the program is terminated, maybe that won't always be true. In the future we could add on support for multiple windows, and might forget that we didn't properly implement a destructor for the window and introduce a bug. In general, the behaviour of a single class should be complete and not implicitly rely on external behaviour of the rest of the program.
@@BrendanGalea I appreciate your reasoning, I just don't see when closing the window of our game wouldn't mean the program exits (I always just code that way, RAII and OOP paradigms just totally go against my logical reasoning I guess, but that's purely my personal preference!) (EDIT: oops, re-reading my comments they sound kind of argumentative, that wasn't my intent, I was just curious as to why so many people do things that way)
@@phraggers - aha no worries, didn't seem argumentative to me :) But ya the only example I can think of is if you have multiple windows in your engine, that can be opened/closed dynamically at runtime. Since one window may be closed, but other windows could still be open, the engine would keep running and we'd want that windows resources to be properly cleaned up.
Hey, I know I'm kinda late, but I've been following the tutorial and I've been getting VK_ERROR_NATIVE_WINDOW_IN_USE_KHR when creating the window surface, really don't know what is causing this since I dont have any other active swap chains, any help would be appreciated.
Great tutorial! Something weird happened when I was following along. I got an undefined reference error in main.cpp when I initialized the app variable using curly braces. When I removed the curly braces, it compiled successfully. Next, I added the curly braces back in, and suddenly it didn't throw the error anymore. What happened??
That is strange. Did you get the error in just the ide or also when you compiled for the first time? Which ide are you using btw? And which compiler if you know? And also what version of c++. Make sure to be using c++17 or newer
@@BrendanGalea I used VS Code on pop os, and c++20 with gcc. I was using cmake btw. And I forgot to mention earlier: the error showed up on the line where I called app.run()
@@Levendo hmm ya im not sure. Let me know if it comes back. My best guess would be that maybe the IDE just wasn't detecting this include paths until after trying to build the project for the first time.
Vulkan is a low-level API used for 3D graphics and GPU computing. Vulkan is not a game engine (like Unity), widget toolkit, render engine, or otherwise.
hey windows ppl, if you're having a hard time setting up Vulkan and can't get the window popping as showed in the beginning, this video helped me fixed the issue: ua-cam.com/video/d2jkALhm9EE/v-deo.htmlsi=yZOyPcu_rfFqFzlQ - basically make sure you're using visual studio and NOT visual studio code. Yes, bummer, but hey that's life lol. - the guy goes pretty much in depth and also talks about relative and absolute linking (very important thing to know when doing Vulkan development) hope this helps!
@@br4yd3 So for xcode follow the steps here vulkan-tutorial.com/Development_environment#page_MacOS, it can be tricky because if you miss a single step or your search paths are not exactly right then it won't work. I'm not exactly sure how I set up with vscode on a mac. I'm pretty sure I downloaded the macos vulkan sdk, and then just followed the tutorial for the Linux section but skipping over the "Vulkan Packages" section and started from installing GLFW. If you've already brew installed glfw and glm then I think you shouldn't sudo apt install them again. Just skip all the way to "Setting up a makefile project". Then in vscode, configure it as you would for any type of c/c++ dev, so you'll probably want to add the c/c++ intellisense extension. To get proper code completion working you will need probably need to create a c_cpp_properties.json file and make sure in the includePath you have the path to the location of the macOS vulkansdk. example: code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
There exists a runtime library called moltenVK that acts as a compatibility layer between vulkan and metal. This allows vulkan applications to run on macOS/iOS. However I haven’t looked into this in much detail so I don’t know if there’s a noticeable performance cost. So far all the tutorials are coded on a 2018 mbp
Hi your video is very nice But I'm having a very strange problem. In initWindow, the last line is simply ignored With GDB, I put two breakpoints, one at glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); and another on window = glfwCreateWindow(width, height, windowName.c_str(), nullptr, nullptr); and it just doesn't fall in the second It's more strange because using the setup code ran without problems
It's a wayland error. The error is about stealing focus. I prefer to ignore this error and develop on windows. I tried the ones from glfw's github but without success, if anyone knows the solution I would appreciate it
I get this error after I added the shouldClose(). while (**!lveWindow**->shouldClose()): Type name is not allowed (The **BOLD** is the part causing the error and I don't know how to underline in UA-cam).
@@BrendanGalea Thanks for the fast reply! The error message is "Type name is not allowed". I tried using a dot, but still got the exact same error message. I am using Visual Studio 2019.
@@nsa3967 That's really strange, because all we're doing is calling a function we declare from another class. You added the classname scope before the function name? So FirstApp::run() { ... } and not just run() {..} I'd recommend going through the code again to make sure you haven't missed anything, or go to the github repo and download the tutorial 1 code and see if that compiles.
@@BrendanGalea Yeah I've double checked and it seems like it's fine. I'm gonna compile it from your Github and let you know if it works. Thanks for the reply!
hey there i have just started learning c++ i have learned all the basic stuff but i wonder where do you learn and come up with solutions with the coding like for instance you used the destructer in the code for window like where do you learn this advance level stuff from ? ..
The enum class over enum warning can be safely ignored. That’s present because I used the c vulkan bindings opposed to the cpp vulkan headers. But other than that the code should work.
Ya I wasn't able to get things working with vscode on windows. The last time I tried I ended up giving up and just setting up visual studio. I'll give vscode another shot now and see if I can figure it out and will let you know.
haha ok this took longer than I expected but I got with working :) This is the build command in the vscode power shell g++ -std=c++17 -I. -IX:\VulkanSDK\1.2.154.1\Include -IX:\dev\Libraries\glm -IX:\dev\Libraries\glfw-3.3.2.bin.WIN64\include -o main.exe *.cpp -LX:\dev\Libraries\glfw-3.3.2.bin.WIN64\lib-mingw-w64 -LX:\VulkanSDK\1.2.154.1\Lib -lglfw3 -lvulkan-1 -lgdi32 -static-libgcc -static-libstdc++ You will have to update the filepaths of course based on where you have stuff saved The last two flags -static-libgcc -static-libstdc++ may be unnecessary, I think I was having some issues because I had mingw32 installed elsewhere on my computer which was causing conflicts. Make sure to update your Path system environment variable to in include wherever your ../mingw64/bin is After updating Path make sure to close and reopen vscode, I got caught up on that for a bit. This is a good guide for configuring some stuff in vscode and going over how to update Path. code.visualstudio.com/docs/languages/cpp If you have any questions I'll answer them as soon as I can but I may not be able to get to them until tomorrow!
My first guess would be something to do with the dependencies (glm, vulkan, glfw) not getting properly included. But you can join the discord and share them in the debugging_help group and I'll see if I can help resolve the errors - discord.gg/CUQkuKsszr
@@BrendanGalea i'm using VSC on win10, i installed MinGW using MSYS2, and i'm using a makefile like shown in the linux part of the tutorial (i saw you were using one so i decided to follow along), however the $(LDFLAGS) thing doesn't work and g++ outputs that it couldn't find every single of those flags
Ya the makefile I provided would only work for linux or macOS. It was a bit tricky but this is what I came up with, I tested it on win10 and it seems to work. Makefile ------------------------------------- include .env ifeq ($(OS),Windows_NT) RM = del /Q /F CP = copy /Y ifdef ComSpec SHELL := $(ComSpec) endif ifdef COMSPEC SHELL := $(COMSPEC) endif else RM = rm -rf CP = cp -f endif CFLAGS = -std=c++17 -I. -I${VULKAN_SDK_PATH_INCLUDE} -I${GLM_INCLUDE} -I${GLFW_INCLUDE} LDFLAGS = -L${GLFW_LIB} -L${VULKAN_SDK_PATH_LIB} -lglfw3 -lvulkan-1 -lgdi32 TARGET = main.exe ${TARGET}: main.cpp g++ $(CFLAGS) -o ${TARGET} main.cpp $(LDFLAGS) .PHONY: test clean test: ${TARGET} .\${TARGET} clean: ${RM} .\${TARGET} .env file --------------------------------------- VULKAN_SDK_PATH_INCLUDE = X:\VulkanSDK\1.2.154.1\Include VULKAN_SDK_PATH_LIB = X:\VulkanSDK\1.2.154.1\Lib GLM_INCLUDE = X:\dev\Libraries\glm GLFW_INCLUDE = X:\dev\Libraries\glfw-3.3.2.bin.WIN64\include GLFW_LIB = X:\dev\Libraries\glfw-3.3.2.bin.WIN64\lib-mingw-w64 And then to run the makefile, in windows powershell within the project directory I ran C:\MinGW\bin\mingw32-make.exe Let me know if that works for you!!
Hmm i dunno but i prefer to not include template monsters like glm. Also the Entire OOP trash is not really what i like. Wtf why did you wrap the glfw window when you never create a native window anyways. Also even more important why did you start with abstractions before you even knew the usage code or made some usage code.
Yes that's a good point! They can slow compile time and I don't believe you would see glm being in completed engines. But for when learning I think it's a very easy to use and understand vector library. But of course feel free to use your vector library of choice, or you could even create your own! I think your confusion may be from me not communicating well enough what this series is. My aim for this series is to create a more beginner friendly 3d graphics/game engine using the vulkan api and not the most optimized engine. So I have a lot of focus on theory and many concepts that if you've worked with other graphics APIs you may already know. So for as far as design decisions go, I'm always trying to balance being clear and educational, but also concise and trying to minimize backtracking, and then the lowest priority for now is on being optimal. (And then of course I may also make a mistake!) I will be using lots of OOP so you may not like this series though! But vulkan is a fantastic C API so there is absolutely no reason that if you want to use vulkan that you'd be stuck using OOP, that was just my choice. I'm sure someone else has or will create a vulkan series not using it.
@GigaramsYT Thank you for the feedback, this is my first time creating a series of tutorials so there has been a pretty big learning curve! I agree that I didn't give an adequate explanation of what a window is and why I was creating an abstraction for it. And for namespaces I also should've communicated my intention and why I've been wrapping all the code. It's because I intended this to also work as a library and therefore I wanted to avoid potential naming conflicts, but in hindsight this was probably a mistake for this tutorial series... oh well I'm kind of stuck doing it now. If you want to follow the series, leaving out the namespace shouldn't affect things though. Once the series is over I'll have to make a video going over all the things I should've done differently :p Anyway I really appreciate the feedback!
Man I was excited about this series, but using namespaces trashes my comprehension of code. I think it is especially a mistake to use them when teaching, because the learner is blinded to the structure of the code.
I had never considered that, but I'm not sure I fully understand what you mean. Doesn't the use of namespaces make the structure of the code more clear? Or do you mean for example, using namespace std; ? Because I won't be doing that in the series because it can potentially result in naming collisions, pollutes the global namespace, and that does make the structure of the code more difficult to understand.
you are absolutely correct! If I said it's a game engine in the video that's incorrect. The tutorial series is on how to make a game engine using vulkan
man your video is good but for tutorial your codes are very hard to understand ,i use SDL2 for window creation it should be easy for me but i found your videos are not good for tutorial ,you should use simple codes to do it if you are making a tutorial
#GLFW_INCLUDE_VULKAN apprently is an "invalid preprocessing directive" for me. Looking around and found out it is just a directory to the vulkan.h file, so if you go to the path to your include files, and then vulkan/vulkan.h. I think this was something I've messed up in the setup so I will proberbly go back but just if anyone wants to quickly see if their code works.
I'm so pumped!! Finally someone is doing vulkan tutorials! Thanks a lot!
I almost gave up on learning Vulkan until I found your videos. Thank you a lot :)
I've just started to learn Vulkan. This is like the most instructive and simple tutorial I've seen on the subject. Thank you and keep up the good work
Vulkan*
This is the easy part
@@astrainvictum9638 hahahaha yes indeed
I'm stumped on the validation layers; which is like, step 2 LOL
This is the first series on Game Engine programming that is easy to follow, elaborate, and practical. This can serve as learning material, as well as a base for one's own engine, because of the implemetation of common and practical tools such as GLFW, Vulkan.
Please keep on updating
I've waited thousand years for something like this, thanks for this
Summer starts soon, so I'm thinking of watching this series seriously. The best part about it so far in my opinion is that it seems to be all laid out and planned (4:15 - "Which we'll cover in around episode 10"!)
One other thing I've just thought about is that the code hints + documentation are convenient to pause and read about as I watch (as one being unfamiliar with C++)
I absolutely love that you are using a modern C++ approach with RAII and stuff. The world really needs more people like you ❤
The really cool thing about this Brendan is that as a Mac user (and I love my mac) I was so frustrated to find that opengl is no longer an option due to Apple not supporting it. I have been looking into getting a windows pc to get into 3D stuff and then I find this Vulkan (that i hadn't heard of) and that it runs in Xcode. Perfect, thanks so much.
Dude! This is gold! I can't wait to watch the rest! I can actually follow what you are doing!
Incredibly fluent and break down very complex API setup in a very clear manner. Thank you again!
I think I'm finally ready to start learning Vulkan. Thanks for making this series! I just finished this video and I'm excited to continue, really thank you for making these videos. It's an invaluable resource!
4:00
Don’t you mean “since we’re not using OpenGL”
Great video btw, can’t wait to watch the other tutorials.
Hahaha whoops! I’m surprised nobody else has mentioned that
finally after a week or so I AM AT THIS STAGE- ik it probably took u guys 4 mins but it took me long to understand everything in ep 0-
ya vulkan/computer graphics in general is a complicated beast. It's definitely an industry that has advanced as quickly as it has due to passion. Takes a lot of patience and trial and error to learn. I've been learning for over a decade, and still have much to learn! Hopefully this series can be a helpful part on your journey :)
@@BrendanGalea man this month i kept jumping from a game engine to another but now i feel like most game engines at this time use opengl which is old and i been trying to make a complex game in both godot and unity but bending the engine around to fit my needs felt hard lol ig makin a game engine is the way to go good luck bro i am excited to see what both of us can come up with in the future
I love your videos. You opened up Vulkan for me.
THANK YOU SO MUCH!!!!!!!!
I'm so glad they have been helpful!
Your keyboard sounds are so satisfying!
Glad you like them! But I think by tutorial 2 I stopped including them 🤦
Really excited for this series! Subscribed and keen to see what Vulkan is all about ;)
Thanks for subscribing! Enjoy!
Thank you for all of this! I'm very excited to get all the way through your series.
It also feels like learning well writen c++. nice
exactly what I thought.
Great tutorial. Precise and clear on all aspects and at just the right pace. Thanks!
Thank you for sharing your knowledge, first contact with vulkan and loving it :)
very helpful and easy to understand compared to many others videos. Thank you for the perfect training.
I can't believe I kinda actually got it working after googling like 50 different errors :))
Glad you got it working!
@@BrendanGalea i see you made some changes in the reference code. at first i got 118 errors.
among which "FirstApp" is not a member of lve, which you put in there. it should be "first_app". changed that... the error is gone.
I really hope you check errrors before posting the vid. otherwise this is going to be another completely useless tutorial, because it no worky.
@@avatharbehemoth - I'm not sure to which part you are referring to, do you have a timestamp? first_app is the file name, but the classes name is FirstApp
I do run all the code on windows (starting after tutorial 5), linux and macos before posting so it should be mostly free of errors, but any mistakes that do come up after posting I will make a pinned comment :)
@@BrendanGalea
So at the end of the video when i tried to compile i had 118 errors.
Some were mine where i forgot a "}", ")" a ";" or something. Others were far more challenging.
After i fixed those i had 5 errors left
I ended up changing the class name to "first_app" in first_app.cpp, hpp and main. in order to get it to work.
Had some serious documentation to read, errors to google and the last error was probably the most challenging.
Unhandled exception at 0x00051526 Access violation reading location 0x00000004/return glfwwindowshouldclose(window) unhandled exception.
Since the window was a null pointer. and you wanted to return it as a boolean.
Love the tutorials so far!
please continue this series
This is what I was looking for!
It's cool that you've got a terminal window in Xcode, I'm using 12 and only seem to have a console but not terminal and the other stuff.
I’m using vscode! Xcode is great too but I like vscode because it is multi platform.
@@BrendanGalea that’s cool I thought viscose was just c# on Mac. Will check that out then. Suppose you just follow visual studio to set up project. Will give it a go
Actually for vscode follow the ubuntu set up. Visual studio (somewhat confusingly) is a different editor and only specific to windows.
Definitely need to rewatch the videos again after following along the first time. Struggling to keep up with the typing and also listen to the explanations lmao
Okey, it is working for me now... thx for the help with the setup... : )
Sorry! When I first started this I felt uncomfortable recommending a particular setup. But I should probably get around to creating a video at least showing how to set things up as I have them
@@BrendanGalea Dont worry! It is fine I got thow it :)
really nice tutorial and good pace👍
Teaching Vulkan.
That's very much great 😊👍
i really apreciate your help with dowloanding this software
Thank you for the excellent videos 👍
Thank you for this tutorial Brendan. I'm following this on Windows. In this video, when you ran the code before implementing run(), and nothing happened, something felt unintuitive about that, because we already wrote the code to initialise the window, so I was expecting the window to open. Well I tried running the code without the run() implementation, and found that for me, the window opens for a split second then closes. Here's my theory on this, please anyone correct me if I am wrong: I guess this is because the default nature of the GLFWwindow is to destruct after it has gone through a single polling cycle. Question: Does this mean we are recreating the window at a very fast rate to give the illusion of a single steady window? It makes me wonder about how the game loop is integrated within an already running while loop too. Thank you!
Thank you for this!
thanks for the tutorial, straight to the facts and no fancy writing, like KISS principle. Btw why are you using another class to initialize the first class constructor with static variables inside the second class? Would be simpler to just initialize the values inside the first class itself for the window
thanks you just blew my mind
instructions unclear, now the rain is entering my house
You are such a unit man. These videos are so well made. Great job
Great resource. Thank you.
thanks for the help it help my every thing i need to install
Круто, жаль английский не знаю, но видимо материал достойный!
как ты собрался программировать если английский не знаешь?
7:32 the ultimate power: predicting an error before it even happens.
The only greater power: being able to write 1000+ lines of code, compile and run with no errors 😁
it worked! thank you so much!!
0:53 I got the example program running on my computer on Linux and the empty window shows up. However, instead of having a solid gray background color, it "screenshots" whatever was beneath the window before it was created, as if the program had frozen. Was that supposed to happen?
Good stuff!
Thanks! That was really helpful.
I've been working on the code in this tutorial for a couple days now, pretty new to c++. I have a few questions. 1. why does GLFWwindow* window; not need to be initialized? 2. in first_app.hpp why does LveWindow lveWindow (WIDTH, HEIGHT, "Hello Vulkan!" }; use {} instead of ()? Thanks for all the work you put in the series man, I'm a bit of a dumb ass though.
1. We initialize window in the constructor, so it doesn't need to be initialized immediately in the header.
2. You could used (), {} initialization is just an alternative way to initialize things. For more details: www.learncpp.com/cpp-tutorial/variable-assignment-and-initialization/
GLFW and SDL libraries, any others, GLFW does it only work on computers, not phones, tablets, consoles, or any other devices? What about SDL or alternatives to use if I want to make sure my app/game can function on ANY device?
This is a great set of tutorials, thanks Brendan! I've just completed this tutorial 01 and instead of a blank window mine is filled with a copy of what was underneath it when the window was created, as if it took a screenshot. Any idea what could be the cause?
Thanks! And I don’t think that is something to worry about. Might just be how your OS defaults the pixels and we haven’t cleared or drawn over them at this stage yet.
Awesome video, when I try running the project the background of the window looks like a screenshot of the upper right of my screen, though I suspect thats a cinnamon desktop bug haha
ya i wouldn't worry about that at this point. It's just a quirk of how different operating systems handle the initial value for the window at this point. Once we start rendering it won't be an issue.
How did you set it up for Visual Studio Code? I see that the Vulkan Docs use Microsoft Visual Studio. It is probably more complicated in VS Code than VS I'm guessing. I was just curious because I use VS Code quite a lot. Thanks for the videos.
I’ve been using Linux and macOS. It should be possible to set things up on vsCode for windows, maybe with using cmake. Just getting the build settings right might take some time. It’s something I’ve been meaning to do
@@BrendanGalea Thanks for that. I'll try to use make, and I'll also do some more research on build settings.
@@BrendanGalea please do, you're only person I've found doing so on youtube, literally no useful tutorials from anyone else !
I've been meaning to set this up with VSCode on Windows. You just have to modify some json environment files in VsCode to let it know what include paths to add in, but otherwise, it should work just the same after pressing "Build"
If I find any good tutorials, I'll post them here!
@@rogerwinright2290 If you find anything please share, I've been doing the series using VS Community because I don't know how to include the libraries in VS Code.
Thank you!
so tempted to do this in Rust, but I don't know Rust well so maybe I should focus on getting things working in C++ first lol
Don't believe but it really worked
Dumb question: I see that there is a lot of 3D stuff in the later videos, but could I also learn all the things necessary to use the knowledge for making a 2D stuff?
I guess 2D is just 3D but without the Z coordinate, but I'm new to all of this. I will still go through all videos as I am interested in the process anyway, if it will be useful or not for my end goal :p
Yup! Rendering 2D will work just fine. For the most part you’d use all the same 3D stuff except you’d probably use an orthographic projection matrix instead of a perspective projection.
I do plan on covering some 2D topics in the future as well such as sprite rendering.
@@BrendanGalea Thank you so much for replying! Looking forward to seeing those videos in the future ^o^
What code formatting tool are you using for you VS Code C++ projects?
4:00 Is that a speak-o (spoken typo)? You mention not wanting to create an OpenGL context, and then say since we're not using Vulkan
Haha yes! Surprised I didn’t notice that during editing
I have a question about the construction of your logical device. Why, when describing VkDeviceQueueCreatInfo, you also describe VkDeviceCreatInfo, the feeling is that you are creating two logical devices.
what's the timestamp for the part you are referring to? Only one logical device is being created. A device queue and device are different things. One device can have multiple device queues.
Hats off
What is .env file, because I've followed vulkans tutorial and there was no files such as .env or .env-example. Anyone know?
Just a configuration file that specifies the filepaths to locate libraries, object files, etc. the reason I use a .env file is that I don’t commit it to the GitHub so that when developing on different machines they can each specify their own filepaths.
.env is just a common name for a file that is used to specify local environment information specific to the machine running the code and not meant to be shared. The .env_example is just used as a template for the env file to remember what the variable names are
@@BrendanGalea thanks
Hey, How did you do this in VSCode @ 04:18 when you drag-and-dropped the function onto the other one to fix it?
Oh that was just a quick double click to select the function name and then copy and paste
Very cool. Confused about a couple of things: Why use a destructor for the window, if we don't have a window the application should surely close (and then we just let the OS clean up right?) also why use a std::string to pass the window title when glfw expects a char* (so you're converting char* into string then back into char* again with .c_str() ..) It's just that I see these practices shown in every c++ tutorial on youtube and they make no sense to me at all.
I think the reason most c++ tutorials use strings because they tend to be easier to work worth, (string concatenation, getting length, etc.) and whenever a c-style char * is required, they can easily be converted by using the c_str() function.
The destructor for the window is just good programming practices. Even though when the window is closed the program is terminated, maybe that won't always be true. In the future we could add on support for multiple windows, and might forget that we didn't properly implement a destructor for the window and introduce a bug.
In general, the behaviour of a single class should be complete and not implicitly rely on external behaviour of the rest of the program.
@@BrendanGalea I appreciate your reasoning, I just don't see when closing the window of our game wouldn't mean the program exits (I always just code that way, RAII and OOP paradigms just totally go against my logical reasoning I guess, but that's purely my personal preference!) (EDIT: oops, re-reading my comments they sound kind of argumentative, that wasn't my intent, I was just curious as to why so many people do things that way)
@@phraggers - aha no worries, didn't seem argumentative to me :)
But ya the only example I can think of is if you have multiple windows in your engine, that can be opened/closed dynamically at runtime. Since one window may be closed, but other windows could still be open, the engine would keep running and we'd want that windows resources to be properly cleaned up.
would u recommend vulkan ? or smth else ?
Hey, I know I'm kinda late, but I've been following the tutorial and I've been getting VK_ERROR_NATIVE_WINDOW_IN_USE_KHR when creating the window surface, really don't know what is causing this since I dont have any other active swap chains, any help would be appreciated.
Great tutorial! Something weird happened when I was following along. I got an undefined reference error in main.cpp when I initialized the app variable using curly braces. When I removed the curly braces, it compiled successfully. Next, I added the curly braces back in, and suddenly it didn't throw the error anymore. What happened??
That is strange. Did you get the error in just the ide or also when you compiled for the first time?
Which ide are you using btw? And which compiler if you know? And also what version of c++. Make sure to be using c++17 or newer
@@BrendanGalea I used VS Code on pop os, and c++20 with gcc. I was using cmake btw. And I forgot to mention earlier: the error showed up on the line where I called app.run()
@@Levendo hmm ya im not sure. Let me know if it comes back. My best guess would be that maybe the IDE just wasn't detecting this include paths until after trying to build the project for the first time.
10 minutes to create a Window ? Yeah im good 😂 Unity is looking real good right now
Well what were you thinking choosing vulkan? From the official vulkan programming guide “Vulkan is very verbose”.
Vulkan is a low-level API used for 3D graphics and GPU computing.
Vulkan is not a game engine (like Unity), widget toolkit, render engine, or otherwise.
hey windows ppl, if you're having a hard time setting up Vulkan and can't get the window popping as showed in the beginning, this video helped me fixed the issue:
ua-cam.com/video/d2jkALhm9EE/v-deo.htmlsi=yZOyPcu_rfFqFzlQ
- basically make sure you're using visual studio and NOT visual studio code. Yes, bummer, but hey that's life lol.
- the guy goes pretty much in depth and also talks about relative and absolute linking (very important thing to know when doing Vulkan development)
hope this helps!
i dont have the .env files wear do i get them please and thanks
im stuck with out them
I am very new with makefile stuff and I don't no how to use cmake
How did you get it so it doesn't show errors under the include statements for the glfw3, and the vec4?
does your code compile and open a window? What editor are you using?
@@BrendanGalea I have the same problem, I am using XCode.
Also, How did you get it to work in VSCode? I have been looking for a tutorial or documentation for the past week.
@@br4yd3 So for xcode follow the steps here vulkan-tutorial.com/Development_environment#page_MacOS, it can be tricky because if you miss a single step or your search paths are not exactly right then it won't work.
I'm not exactly sure how I set up with vscode on a mac. I'm pretty sure I downloaded the macos vulkan sdk, and then just followed the tutorial for the Linux section but skipping over the "Vulkan Packages" section and started from installing GLFW. If you've already brew installed glfw and glm then I think you shouldn't sudo apt install them again. Just skip all the way to "Setting up a makefile project".
Then in vscode, configure it as you would for any type of c/c++ dev, so you'll probably want to add the c/c++ intellisense extension. To get proper code completion working you will need probably need to create a c_cpp_properties.json file and make sure in the includePath you have the path to the location of the macOS vulkansdk.
example: code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
@@BrendanGalea
g++ -std=c++17 -I. -I/home/Vulkan//include -o a.out main.cpp -L/home/Vulkan//lib `pkg-config --static --libs glfw3` -lvulkan
/bin/sh: pkg-config: command not found
In file included from main.cpp:2:
/usr/local/include/GLFW/glfw3.h:111:12: fatal error:
'vulkan/vulkan.h' file not found
#include
^~~~~~~~~~~~~~~~~
1 error generated.
I thought macOS doesn’t support vulkan natively then how are you doing this series on a mac?
There exists a runtime library called moltenVK that acts as a compatibility layer between vulkan and metal. This allows vulkan applications to run on macOS/iOS.
However I haven’t looked into this in much detail so I don’t know if there’s a noticeable performance cost. So far all the tutorials are coded on a 2018 mbp
4:00 "Since we've not using Vulkan" I assume you meant to say OpenGL?
Yup! Lol
Hi Brendan, thank you for the great tutorial. I was wondering why am I getting this error? undefined reference to `lve::LveWindow::~LveWindow()'
Did you define the destructor in the window header at 2:52
@@BrendanGalea yes i wrote public:
LveWindow(...)
~LveWindow();
i am getting the same error with first app on cmake
Is there any tutorials using C?
Thanks!
Hi your video is very nice
But I'm having a very strange problem. In initWindow, the last line is simply ignored
With GDB, I put two breakpoints, one at glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); and another on window = glfwCreateWindow(width, height, windowName.c_str(), nullptr, nullptr); and it just doesn't fall in the second
It's more strange because using the setup code ran without problems
It's a wayland error. The error is about stealing focus. I prefer to ignore this error and develop on windows. I tried the ones from glfw's github but without success, if anyone knows the solution I would appreciate it
the code works fine, but now window comes up. WHats the problem?
I get this error after I added the shouldClose(). while (**!lveWindow**->shouldClose()): Type name is not allowed (The **BOLD** is the part causing the error and I don't know how to underline in UA-cam).
What's the error message? And I think it should be a dot and not an arrow since LveWindow isn't a pointer.
So lveWindow.shouldClose()
@@BrendanGalea Thanks for the fast reply! The error message is "Type name is not allowed". I tried using a dot, but still got the exact same error message. I am using Visual Studio 2019.
@@nsa3967 That's really strange, because all we're doing is calling a function we declare from another class.
You added the classname scope before the function name?
So FirstApp::run() { ... } and not just run() {..}
I'd recommend going through the code again to make sure you haven't missed anything, or go to the github repo and download the tutorial 1 code and see if that compiles.
@@BrendanGalea Yeah I've double checked and it seems like it's fine. I'm gonna compile it from your Github and let you know if it works. Thanks for the reply!
thanks for the tutorial,,,, build succeed but the window is not opening
hey there i have just started learning c++ i have learned all the basic stuff but i wonder where do you learn and come up with solutions with the coding like for instance you used the destructer in the code for window like where do you learn this advance level stuff from ? ..
How do I setup vulkan in vscode? I dont want to use Xcode.
the same as xcode
I CAN NOT LOAD MY CODE! I say: 'VkResult' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
The enum class over enum warning can be safely ignored. That’s present because I used the c vulkan bindings opposed to the cpp vulkan headers.
But other than that the code should work.
The full series of tutorial videos: ua-cam.com/video/Y9U9IE0gVHA/v-deo.html
can anybody help me setup on mac
im in love with you
Making a vulkan game engine by myself just wanted to see how to link it lol
Okk I started pulling my hair...😓 I'm using vs code and mingw done with adding lib and include files to mingw folder but not working....
Ya I wasn't able to get things working with vscode on windows. The last time I tried I ended up giving up and just setting up visual studio.
I'll give vscode another shot now and see if I can figure it out and will let you know.
@@BrendanGalea that would be a big help...I trying as well ...this this mingw64
haha ok this took longer than I expected but I got with working :)
This is the build command in the vscode power shell
g++ -std=c++17 -I. -IX:\VulkanSDK\1.2.154.1\Include -IX:\dev\Libraries\glm -IX:\dev\Libraries\glfw-3.3.2.bin.WIN64\include -o main.exe *.cpp -LX:\dev\Libraries\glfw-3.3.2.bin.WIN64\lib-mingw-w64 -LX:\VulkanSDK\1.2.154.1\Lib -lglfw3 -lvulkan-1 -lgdi32 -static-libgcc -static-libstdc++
You will have to update the filepaths of course based on where you have stuff saved
The last two flags -static-libgcc -static-libstdc++ may be unnecessary, I think I was having some issues because I had mingw32 installed elsewhere on my computer which was causing conflicts.
Make sure to update your Path system environment variable to in include wherever your ../mingw64/bin is
After updating Path make sure to close and reopen vscode, I got caught up on that for a bit.
This is a good guide for configuring some stuff in vscode and going over how to update Path. code.visualstudio.com/docs/languages/cpp
If you have any questions I'll answer them as soon as I can but I may not be able to get to them until tomorrow!
@@BrendanGalea Awesome.....😮yesterday I did something stupid, today I'm going to try your method.....thanks a lot.... : )
what is the meaning of lve ?
little vulkan engine
@@Banaannaa thanks 👍
Seems pointless to use a wrapper in this case
Hey Brendan, I am using C++ ISO 20 and VS2019 IDE but there are 35 errors, I want to send them to you so you can help me
My first guess would be something to do with the dependencies (glm, vulkan, glfw) not getting properly included.
But you can join the discord and share them in the debugging_help group and I'll see if I can help resolve the errors - discord.gg/CUQkuKsszr
Developement environement tutorial doesn't work.
Which environment are you using. Maybe I can help
@@BrendanGalea i'm using VSC on win10, i installed MinGW using MSYS2, and i'm using a makefile like shown in the linux part of the tutorial (i saw you were using one so i decided to follow along), however the $(LDFLAGS) thing doesn't work and g++ outputs that it couldn't find every single of those flags
Ya the makefile I provided would only work for linux or macOS. It was a bit tricky but this is what I came up with, I tested it on win10 and it seems to work.
Makefile
-------------------------------------
include .env
ifeq ($(OS),Windows_NT)
RM = del /Q /F
CP = copy /Y
ifdef ComSpec
SHELL := $(ComSpec)
endif
ifdef COMSPEC
SHELL := $(COMSPEC)
endif
else
RM = rm -rf
CP = cp -f
endif
CFLAGS = -std=c++17 -I. -I${VULKAN_SDK_PATH_INCLUDE} -I${GLM_INCLUDE} -I${GLFW_INCLUDE}
LDFLAGS = -L${GLFW_LIB} -L${VULKAN_SDK_PATH_LIB} -lglfw3 -lvulkan-1 -lgdi32
TARGET = main.exe
${TARGET}: main.cpp
g++ $(CFLAGS) -o ${TARGET} main.cpp $(LDFLAGS)
.PHONY: test clean
test: ${TARGET}
.\${TARGET}
clean:
${RM} .\${TARGET}
.env file
---------------------------------------
VULKAN_SDK_PATH_INCLUDE = X:\VulkanSDK\1.2.154.1\Include
VULKAN_SDK_PATH_LIB = X:\VulkanSDK\1.2.154.1\Lib
GLM_INCLUDE = X:\dev\Libraries\glm
GLFW_INCLUDE = X:\dev\Libraries\glfw-3.3.2.bin.WIN64\include
GLFW_LIB = X:\dev\Libraries\glfw-3.3.2.bin.WIN64\lib-mingw-w64
And then to run the makefile, in windows powershell within the project directory I ran
C:\MinGW\bin\mingw32-make.exe
Let me know if that works for you!!
Hmm i dunno but i prefer to not include template monsters like glm. Also the Entire OOP trash is not really what i like. Wtf why did you wrap the glfw window when you never create a native window anyways. Also even more important why did you start with abstractions before you even knew the usage code or made some usage code.
Yes that's a good point! They can slow compile time and I don't believe you would see glm being in completed engines. But for when learning I think it's a very easy to use and understand vector library. But of course feel free to use your vector library of choice, or you could even create your own!
I think your confusion may be from me not communicating well enough what this series is.
My aim for this series is to create a more beginner friendly 3d graphics/game engine using the vulkan api and not the most optimized engine. So I have a lot of focus on theory and many concepts that if you've worked with other graphics APIs you may already know.
So for as far as design decisions go, I'm always trying to balance being clear and educational, but also concise and trying to minimize backtracking, and then the lowest priority for now is on being optimal. (And then of course I may also make a mistake!)
I will be using lots of OOP so you may not like this series though! But vulkan is a fantastic C API so there is absolutely no reason that if you want to use vulkan that you'd be stuck using OOP, that was just my choice. I'm sure someone else has or will create a vulkan series not using it.
@GigaramsYT Thank you for the feedback, this is my first time creating a series of tutorials so there has been a pretty big learning curve! I agree that I didn't give an adequate explanation of what a window is and why I was creating an abstraction for it.
And for namespaces I also should've communicated my intention and why I've been wrapping all the code. It's because I intended this to also work as a library and therefore I wanted to avoid potential naming conflicts, but in hindsight this was probably a mistake for this tutorial series... oh well I'm kind of stuck doing it now.
If you want to follow the series, leaving out the namespace shouldn't affect things though. Once the series is over I'll have to make a video going over all the things I should've done differently :p
Anyway I really appreciate the feedback!
Man I was excited about this series, but using namespaces trashes my comprehension of code. I think it is especially a mistake to use them when teaching, because the learner is blinded to the structure of the code.
I had never considered that, but I'm not sure I fully understand what you mean. Doesn't the use of namespaces make the structure of the code more clear?
Or do you mean for example, using namespace std; ? Because I won't be doing that in the series because it can potentially result in naming collisions, pollutes the global namespace, and that does make the structure of the code more difficult to understand.
Vulkan is not a game engine, it's an API
you are absolutely correct! If I said it's a game engine in the video that's incorrect. The tutorial series is on how to make a game engine using vulkan
man your video is good but for tutorial your codes are very hard to understand ,i use SDL2 for window creation it should be easy for me but i found your videos are not good for tutorial ,you should use simple codes to do it if you are making a tutorial
#GLFW_INCLUDE_VULKAN apprently is an "invalid preprocessing directive" for me. Looking around and found out it is just a directory to the vulkan.h file, so if you go to the path to your include files, and then vulkan/vulkan.h. I think this was something I've messed up in the setup so I will proberbly go back but just if anyone wants to quickly see if their code works.
Because you're supposed to do #define GLFW_INCLUDE_VULKAN, not #GLFW_INCLUDE_VULKAN