Project Setup | Game Engine Series

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys my name is Jonah welcome back to my gay mentioned series so last time we talked about the entire scope of this series and warnings up who were doing make sure you watch that planning video there and as I explained in that video I don't really want to be planning too much too quickly in the beginning because I mean I actually would like to kind of do that I would like to have just ten episodes of just planning and just figuring everything out because this is such a large project you like you guys have to realize just how big of a project this is but anyway because that would kind of be boring and I also have to kind of balance the entertainment versus production kind of balance I guess of this entire series we're actually gonna dive in and start writing code like today and then as things creep up we're gonna plan for them then and there and because of that because that kind of iterative model that we're gonna do hopefully we'll get stuff actually happening as soon as possible and that way you guys will kind of see results and it'll be more entertaining but also it's a really good web development that I personally also really like because instead of just kind of spending ages building up the older kind of foundation and then like a year later seing a triangle on the screen we kind of get to we're able to get to that stage a lot faster and this is just kind of it's it's better to see if what if what we're doing is even going to work in the first place and then we can always kind of improve it anyway without much further ado um I was spending this entire week kind of planning this series and that's why I kind of just just realized exactly how much is involved here and there's a bunch of like opinions that I really want to share with you guys in probably the coming weeks because the way that we do this is going to kind of impact the series because we either see something on the screen quickly or we wait longer and then get benefits further down the line but anyway again I don't want to talk about planning today so that's just kind of just some loose things on my mind today we're gonna set up everything so we're going to set up a github repository we're going to set up a visual studio solution and projects we're going to set up the configuration for that to some extent and we're going to just kind of link those two link everything together and make a simple obligation that prints hello world to the screen but it will be kind of structured and configured correctly for our actual game engine so the question might be well okay if you're gonna make hub repository if you're going to make a visual studio solution what are you going to call the engine the engine is going to be called hazel hazel engine don't ask me where I came up with that from I kind of liked us going through various nuts or something at work and there was like walnuts and hazelnuts and stuff like that and I really liked hazelnut and hazelnut might end up being like the level editor or some kind of component of it but I just think hazel really nice simple name and I don't think there's any other game engines called hazel so hazel that's the name of our game engine yay congratulations that's actually probably the hardest part is coming up with a name anyway now that we've done that let's go ahead and make that repository okay so here we have my github account it's just github become four slash the channel here it is you following me here what I'm gonna do is just make a new repository I love the fact that I'm doing this in front of all of you guys I'm gonna call it hazel I'm just gonna say hazel engine for now as my description it's gonna be public of course I'm gonna initialize the repository with it readme it for the good ignore we weren't worried about that the time being and for the license I'm going to give it the Apache License 2.0 for me now basically that just means that if someone uses this they have to disclose it who dis in fact the hazel engine as well as as well as like other kind of things like if they modify the source code that also needs to be kind of documented anyway that's kinda basic setup now in terms of github and where all this code is going because I get asked this all the time the car's gonna be 100% free and public anyone can use it just as long as you do state that it is the hazel engine that you're using which i think is fair it's gonna be 100% public every old cars gonna be online so you don't need to like be a patron or anything but speaking of which I do want to thank all of my patrons because this series would not be here without you guys so if you want to support this series and everything I'm doing you can go ahead and go to patron compost after the Cherno you'll get videos like a week early so videos for this series you'll get a week early and then there's also many other benefits to do with this area specifically for example whilst all of this actual code that we write in each video is going to be public for everyone no matter if you're a patron or not I do actually have a private kind of development branch where I've already written like a good chunk of the engine like probably I'd say the first 10 to 20 episodes of we already done and already available as of this video going public it's already available for all patrons and like I mean that's that's just there right because obviously this is a huge engine I don't know I can't type everything in front of you guys so the stuff that I kind of do in my private time when I actually plan and actually write that code to see how everything is going to fit together all of that so basically a working engine does already go up on that private github repository for all of my patrons so that's enough that's another way that you can kind of help support em and in return of course get something as well that being said though the beauty of that is that the page ones get to see the code before it gets written in the video which means that if there's problems with the code or there suggestions people want to make they actually end up contributing and actually helping like basically influence what code actually Zirin in these videos so again huge thank you to everyone for that because that's really really cool anyway let's stop talking about that let's get back to creating this repository okay so this looks pretty good I'm just gonna hit create repository and there you go the hazel engine repository that's really cool I wonder if anyone's gonna notice it's actually becoming public because obviously at the time of a recording this video I haven't actually put out the video yet and yet there's a new repository the script off so that's kind of interesting you can start the repository of course by going here and that way you'll kind of know about changes and all that stuff it's kinda like favoriting it and it helps support that as well but we have a license and a readme file pretty bland so now that we've got all of this we can kind of clone this using git and actually create a visual studio solution and that will be all great now the way that I like to do this because either Visual Studio or get will end up complaining about certain things being already kind of there so in other words if you try and make a you try and clone get if you try and clone and get a map repository into it directly that's not MTA will complain if you try making visuals gif solution into a directory that's not empty that might also not work so what I like to do with this is just hop on over to Visual Studio I'll hit file new project I'm going to make an empty C++ project it's going to be called hazel now of course we will have multiple projects in the solution but I just want the solution name to be hazel and I'm just going to put it into seed dev it's usually a good idea to actually your kind of source for your parent development code into a repository or rather into a folder that isn't tied to your user account so in otherwise I'm just doing si dev it's not kind of you know see users Yamcha knockoff or whatever nothing like that and then also I want to note here that I don't have any spaces in the namespaces can sometimes conflict with certain things not all plugins like spaces I'm looking at a certain Android like plug-in by a certain company anyway doesn't matter the point is try and avoid spaces as much as possible in your actual names at least leading up to the actual kind of root folder of your repository here we have C dev and then hazel and I want to create a directory floor solution and then I'm just gonna hit okay so there we have it the hazel solution pretty cool if I just open this kind of folder so that we can look at it we have a folder called hazel inside we have hazel the hazel solution file and then inside that we actually have a folder called hazel which has a project called hazel so there's a lot of hazel everywhere but that's kind of the idea now what I'm gonna do next is basically just open a command prompt window by typing in CMD here and I have I do have git installed so all I have to do is type in git clone HTTP github.com slash the chanter slash hazel and that's it now of course hey will doesn't exist sorry I forgot that I'm already in here so we can just call it like not a nerd git or something it's just gonna clone it into a folder I don't really care where it is because what I'm gonna do next is actually go into this folder I'm gonna make sure that I look at hidden items this is the dot git folder that we care about and I'm gonna cut this and actually put it into hazel over here right and then delete that git folder now this is what we end up with so basically what I've done is I've managed to cloning that git repository into a folder that was not in fact empty and you can see that this contains our license and readme file that we created kind of through that github repository but then we've also got all of our stuff here which is also really important I'm sure there might be a better way of doing this but this is just the way I do it I'm not a big deal basically all we want is we want create a visual studio solution and a git repository in the same directory so I've done it manually like that okay cool anyway now that's done we can move on to actually setting up our project so what I have here as you can kind of see is essentially a hazel project file and then a hazel solution now our solution is going to contain more than just the engine right hazel is our engine what we want to do is actually build that into a dynamic link library into a dll right on Windows at least is going to be a dll file and then what we want to actually do is create some kind of external application project that will be an executable so on Windows a dot exe file and then we want to actually link that engine into our XE file now there's two ways of doing this primarily you could use a static library or you could use a dynamic library myself plus series has an excellent video about the differences between dynamic and static linking and also all about dynamic and static libraries so check that out if you're not sure what the differences are basically the reason that I'm choosing to go with a DLL apart from the fact that we can kind of load on and unload it as we kind of choose it's primarily because we we're gonna have quite a lot of quite a lot of dependencies quite a lot of libraries that we actually have to linked into our engine to make it work if we go with a static library and we ignore the fact that you can kind of create fat static libraries that's kind of dodgy so if you look at traditional static linking basically what it means is that all of our dependent libraries that we have we actually have to link that into our game our engine might depend on certain libraries but we need to link instead of being able to link all of those libraries into the engine kind of library file we actually have to link everything into the game if that makes sense again static linking is that's just how it works whereas a DLL is basically like an exe file so we can actually link everything into them and then our game will just depend on that single DLL file which will contain everything it needs instead of having a billion other kind of library files so essentially what we end up doing is actually linking everything into that engine dll all about kind of dependencies which means they all need to be static libraries so we link all those static libraries into our engine DLL and then we link that engine dll into our game and that is it that's all we need so that's what we're gonna Mikio someone a right-click on hazel hip properties these are our properties now since my feelers talk a little bit about platforms and configurations we have to kind of configurations to start off with debug and release we can make more further kind of as time goes on we will make more but platform is something that I want to particularly spend some time on because if I go to the configuration manager here we have two kind of solution platforms x86 and x64 now I don't really want to support 32-bit because it's kind of it's 2018 like we 32-bit is not something that I want to support maybe for legacy reasons it might be a good idea so I might riad it back if like people do make the case or if someone really wants it but for me right now I don't 1 x86 so what we're actually gonna do is come down here into edit and remove this x86 platform entirely ok it's gone we also need to remove it from here because it's also been created here so edit win32 same as x64 in terms of visual studios namings and then that's it that's done so this kind of keeps everything a lot cleaner we're going to got one platform now x64 and then still two configurations debug and release since by configuring this I'm gonna go to all configurations I'm gonna change the configuration type this is the big kind of change from AFC to DLL write dynamic library that's very important change because now instead of this building an exe file it builds a DLL I'm gonna keep the Windows SDK where it is as well as the visual shear version at 2017 which is V 141 so it's very important that you guys download Visual Studio I do have a video on how to set up C++ on Windows I suggest you watch it that I didn't want to spend today setting up and installing Visual Studio I think you guys should be already pretty familiar with that this is quite an advanced series and if I start doing things like telling you how to install visual studio we'll be here for decades so please look at my other videos for what kind of tips I guess also help with setting up C++ in general but that being said visuals should be 2017 we are going to primarily target in C++ 17 so lots of modeling there and we definitely need Visual Studio 2017 for that support so the two other things I want to set up here really are the output directory and the intermediate directory because Visual Studio is default set up is not very good if you're gonna look at my video that I'll link up there which is kind of the best way to set up C++ Visual Studio Projects this is gonna be kind of based on that but I've changed a little bit certainly what we want to do is this is all fine but I kind of want to make a folder in the solution directory called bin everything is gonna go there everything all of our binaries all of our libraries all of our kind of projects that we have in the solution everything is going to go and bin and I'm actually going to separate this by the actual configuration so I'm going to say configuration which means debug or release in this case and then a - or - and then the platform okay so this will be something like in this case debug you know x64 I don't want to spent want split this up into two different directories cut it because I don't want like this massive folder hierarchy and then in this case it's just going to be the project name and that's it right so what this is gonna do is for this hazel dll file it's gonna put it in bin-debug debug x64 and then hazel dot dl oh sorry and then hazel and then hazel dot dll and we'll leave a splash at the end of that I want to copy this and paste it into the intermediate directory now there's two ways that I kind of do this you can just add another folder called bin int but I don't really like having too many folders at that core kind of brute solution directory so what I do is I end up just kind of doing bin and in slash end which just stands for intermediates so these are kind of all the files the visual studio needs to create like the obj files for example when it's actually compiling our code definitely safe to delete once has been compiled we don't want to put into the same directory as being necessarily bomb because bin has kind of all of our actual stuff and in fact that's why I don't like doing this in fact I might not actually do this because it's nice to just be able to copy and paste that bin folder and it has everything you need so I might just say bin you know - until something like that which just basically means that I can delete that directory if I want and if I just want to copy and paste bin somewhere because I want all my binaries I don't have actually manually go in there and delete the intermediate directory to kind of keep the file size low so this actually might be better okay cool there we go that stuff is all pretty good let's hit okay next thing I'm gonna do is right-click on my solution file and hit add new project now here I'm going to add an actual game project basically so we have our engine but now we need an application that will use our engine so I'm going to call this sandbox and it's just going to go in to see dev hey we might move it into a directory further along the way like you know examples or like sandbox projects or something like that once we have a few but for now sandbox will be fine okay now once visual sugar creates that I want to copy a lot of the settings from here so of course it's made its own platform which is really annoying and we might actually have to do this every time I shadows later but we'll get because we're using visual Studios templates but we'll get rid of x86 again quickly hazal should still be fine yeah and then we'll get rid of win32 okay that stuff is gone all configurations I'm just going to copy and paste this output directory and then also this intermediate directory and then of course sandbox will actually be an exe file okay cool and that's really all we have to do for now so let's hit OK I'm gonna set sandbox as these startup projects and furthermore I'm actually going to do something now that is going to save some headache probably in the future I'm going to just open the solution directory and then I'm gonna control v 2w well controller double use my keyboard command but I'm basically going to close that solution file close solution is the actual thing that I did that I'm gonna actually open the solution file I just realized that that's going to not open it as a text editor so let's open a text editor and take a look at this solution file I'll open it with Visual Studio code okay so I'm looking at the solution file here and basically all I'm gonna do is I'm actually gonna shift this sandbox project from being the second thing in this list to the first one what that means is for people who kind of check out this repository fresh from github sandbox is actually automatically going to be the startup project instead of hazel because if Hazel's the startup project it's obviously not gonna run its a dll file but this way they can just literally open the solution hit f5 and everything will run so there we go that's done so I'll open this now of course for us if we have a dot vs directory with user settings it's going to remember like which one we left as the startup project so that's all kind of easy for us okay awesome so now let's actually set up a basic enough structure so we have sandbox and we have hazel what I want to do now is just kind of a link these two together someone I right-click on sandbox go to add and then reference and then I'm gonna add hazel as my reference what that means is that now when hazel actually compiles and generates a static library file and a dll file this is going to actually link with that so hazel is going to be linked into sandbox but it's done for us kind of using visual studios interface if we right click and hit properties go to linker command line and then look at debug for example you can see here that if we look through this command line we have this line right which says see dev hazel bin-debug X in situ for hazel hazel dot Lib okay so it automatically links for us that engine library file now you might be like well didn't we make it a dll file why is it a Lib file it's because when we compile the dll file in Visual Studio it actually generates both a Lib file which contains kind of every function that we've actually exported from the DLL file so that we don't have to manually actually Lourdes functions or symbols from the DLL file and then it also generates that dll file which has the actual machine code and any other kind of link stuff as well so that's why we basically can statically link against hazel lib but the DLL file is what we need for a long time okay cool anyway that's how that works looks pretty good to me let's hit okay that is it that's our project set up now I'm going to quickly go over here to hazel and hit the show all files button I'm going to add a new folder called SRC which will contain all about source code I'm going to do this for sandbox making sure that we're on show or Files mode because we want to actually create that says directory on disk and then over here I'm just gonna add a basic header file which is going to be called like literally I'm just going to test this out now because we're already at like 20 minutes and I definitely wanna save the actual code writing for next time but I'm just going to make test dot H and test dot CPP I'm going to write a basic function here namespace hazel and then void print I'm going to include test dot H namespace hazel void print is going to print F hello world or rather let's just say welcome to hazel engine that seems a bit more appropriate will include stdio.h to get that printer function and then what we need to do is actually add eckle spec DLL export that function however we are going to need to include it as well into sandbox so this is gonna be a little bit rough because again I don't want to set this up properly we will set this up properly next time we'll talk about DLL exporting and importing and how to actually get our library set up correctly with the hazel API so we'll talk about that next time but for now we'll simply a dll will export that print function from here we'll hit right click build on the hazel dll now you can see that what's happened is if we go into hit the hazel root directory we have been we have two about x64 we have hazel then we have a hazel DLL file and a hazel Lib file so that dll file is needed to actually run our code but the Lib file gets linked in to sandbox so that it knows which functions are available and where they are in the DLL let's hit a new item in sandbox I'm going to call this application dot CPP this is just going to include well when I'm actually going to include anything I'm just going to type in void main' which is our main function okay and I just want to call this void print now what we're going to have to actually do is for now copy this paste it up here call this deco spec DLL imports avoid prints from the hazal namespace and then I'm just gonna call hazel prints just like that okay and if I right click and build sandbox you should see that we don't get any linking errors or anything like that it's done if I try and run it though it's not going to work because it's going to complain about that DLL file actually missing so again for now we're gonna automate all of this in the future but for now just to show you guys how this works I'm going to go into bin a debug x64 Hazel's copy that DLL file that we've built manually put it alongside sandbox at exe and now hit f5 to run now that worked we can go any errors let's put a breakpoint here so we can actually see what's happened if I hit f10 and I look back on our console you can see it said welcome to hazel engine which we did from within that dll file so there we go we're up and running next time we're gonna continue on and actually write some basic engine code and maybe even write the entry point of our engine alright so that's it I hope you guys enjoyed this video you can see that it's probably getting a little bit long already and I kind of want to keep this between between 10 and 20 minutes so we'll see kind of how we go because inevitably as we get into more complicated things it's gonna be hard but everything that I kind of showed you here even though at the end might seem like I kinda just took a few shortcuts to get stuff working there is no I like doing that it's because you actually see how things work right instead of me kind of setting up automated steps that do everything for us you can actually see what manually needs to be done so that when we do automate it you know what's actually happening but we basically did some very important things today we created that hazal dll file like project write and an actual sandbox project the links with hey Google we set up again our repository we set up a visual studio solution everything is ready to go for us so that next time we can actually dive in and start writing real engine code so that's the setup done right that's all we need to worry about for now I promise you and then next time I'm gonna continue on and actually start writing some engine code which I'm really really excited about I hope you guys know this video if you did hit that like button you can help support this series by got a patron of course - they sure know those people already have the next video up which is really cool so if you want to see that engine code today well you can and it really does help support the series and I'm so thankful for you guys because this would not be here without you all I can't wait to see in the next video goodbye [Music]
Info
Channel: The Cherno
Views: 155,848
Rating: undefined out of 5
Keywords: thecherno, thechernoproject, cherno, c++, programming, gamedev, game development, learn c++, c++ tutorial, game engine series, hazel engine, how to make a game engine
Id: KG8cAGvn9d4
Channel Id: undefined
Length: 24min 39sec (1479 seconds)
Published: Sun Oct 28 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.