Making a New C++ Project in Hazel | Game Engine series

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
it's guys my name is the Jonah welcome back to my game engine series so last time we continued on with the dock space we talked about frame buffers and all that stuff definitely check out that video if you haven't already and today I thought it would have a nice fairly quick hopefully chill episode in which we take a look at what it takes to actually set up a new project in hazel now this is something that when I say that I specifically I'm just talking about like development wise within Visual Studio so this isn't like how to make a new game or new app using hazel because obviously once we have like a whole tool chain and a set of tools for hazel it will be done kind of it there I'm just talking about more or less like we have this sandbox project now if we want to kind of programmatically in a C++ fashion add a new project to Hazel that uses hazel such as a level editor which is what we're going to be doing here today how would we do that because a few few people have actually asked me what that would look like but also it's going to be really important for us because at the moment we're kind of building our editor within sandbox and that's not something that we want to continue doing it's probably a good thing to move that out of there as fast as possible and leave sandbox being our kind of test runtime environment so if we pop over to visual studio let's start off with first of all talking about what we want to do so you can see in the solution Explorer we've got a bunch of dependencies we've got hazel we've got sandbox so what I want to do is create something else called the hazel editor now in the development branch is called hazel nut I don't know if I am 100% sold on that name I think it might be better to kind of keep it more or less simple maybe just call it hazel editor if you guys have any suggestions then um leave a comment below as to if you like the name hazel not if you think hazel editor is better normally in Visual Studio we just go right click add new project and set all that stuff up but we can actually do it a different way in fact we should do it a different way when working with hazel and that is through premake so if we open up the pre make file there's this primary five dollar at the root of the repository I'll just drag this individual studio just to open it in the text editor you can use any text editor obviously since I've got Visual Studio open I'm just going to use that you can see that we've got our hazel project and over here we have else and box projects now the sandbox project is basically what we want to use as like a starting template because haze because sandbox is a console app that obviously links to hazel so if we look at what its kind of made up of we've got the kind of target directory an object directory it is like intermediate directories that pretty much the same as they are in hazel then we've got a list of files which is just again you can save the fairly generic is just project name and then slash source so if we know that hazel not or I keep saying hazel not hazel editor is going to use this kind of same pattern here what we have like you know hazel editor which is the product name and then slash source and then in there all of our source files exist then you can use this obviously otherwise your life if you don't have a source directory you can get rid of it and you guys get the drill include directories these are all kind of things that need to be in an in a hazel app at the moment so basically vendor we use hazel sauce we use that we can actually use like the hazel include directories and stuff like that and then hazel vendor SPG log include as well because like speed log is something that obviously you know we want to be able to also use inside applications that use hazel not just in Hazel's core itself and therefore it needs to be exposed it just links hazel because hazel actually links everything else so that's kind of easy and then we have a few different things here primarily for Windows we just use system version latest this will have a few different like platform specific things as well as configuration specific things but for now it's fairly fairly standard so to make this happen let's copy and paste sandbox one other thing you could do technically is also move this into its own kind of pre mcclure file and then you can actually include it now there's as I think it include is it external or something like that yep so something called include external actually will essentially include the script but I think that this you can include script which might contain one or more project or rule definite and all such containers will be marked as external and simply referenced but not regenerated because every time you included it actually tends to regenerate a project but if you just do include external instead of include it's not actually going to run the Lua script is just gonna include the project so this is something that you can do because like in some situations you might want to include things multiple times because you have multiple solutions that you're potentially generating but you don't want to regenerate the entire project again and again and again because that's not going to be useful at all so that's something that you can do as well we're not gonna bother with that here I'll just because this is like to me this is still call hazel in fact if anything Sam both should be standalone but the hazel editor should probably be inside the hazel solution as well so anyway scrolling down here - so this is the second sandbox and that's the first sandbox we're just gonna call this hazel - editor and location is going to be hazel - editor which means that that's the folder that we have it's going to be a console app C++ it was 417 a static runtime on the total directory and object directory stays the same the files we're gonna use the same structure here this stays the same links hazel everything's the same literally the only thing we've changed is the actual name and that's it so now if we run pre-make not sure anything will happen because we don't actually have that directory set up but if we try to make this happen okay no it does everything it creates the directory for us and it's made of ECX project for us which is great so inside here I want to make a source directory and then I want to put all of my sauce pertinent to this so again as a starting point I'm going to go back here to sandbox and I'm going to grab what I want from sandbox so at the moment I mean we're basically using the entirety of sandbox we're in an example layer but let's take sandbox app and sandbox 2d so I'll copy that and I'll paste it over here and instead of sandbox app I'll pull this hazal editor app that's kind of like our application I guess and then we'll just have editor layer and that'll be our kind of default layer for the hazel editor so now if I go back here to scripts and regenerate the project go back to visual studio hit reload you'll see that I should have a hazel editor over here and we can make like a folder called tools or something like that if you look at the premake file which is actually here you'll see that we have this dependencies folder it's like a solution folder or a filter and the way that that's achieved is just by having a group here so we have like a group dependencies and then under the under that we have certain projects and you can see actually the include external include thing is happening here because it's not included more than once we're just using include because you have to run include the first time but then include external the second time I think I have an OpenGL related video that actually talks a little bit more about that so if you're interested in having pre make files and organizing your kind of I guess solution or project better by having external premake files that you'd then include here so that it's not all cluttered then I'll have the video linked up there which talks a little bit more about how you can organize yourself with pre make a bit better and again that's just not a decision I'm making right now to have this all external I'm just gonna keep it here for now and if this gets huge then I will kind of refactor it and move it out okay but that's really all we need from pre Meg if we go over here the other thing we could do by the way while I'm here is just the start project we could change to hazel editor at the moment I'll leave it as sandbox deliberately because his letter does very much in development has sandbox at least has a like a test running and will actually fix up sandbox today as well so that it doesn't have any of the docs based off and it just kind of has that that original test that we had so if we go to if we go to hazel editor I'm gonna mark that adds this as the start up project and then I'm gonna start refactoring a few of these things so sandbox 2d doesn't exist here it's called editor layer will have will say hazel editor which is a the difference here as well as this well everything here is gonna be inside the hazel namespace because it's part of hazel and that's kind of nice because we don't need to use this everywhere so hazel editor is going to push a layer here and that's going to be I I think I might want to revisit this stuff in the future cuz I'm not sure if I still like the way this is set up but um like you know with with these things well we'll talk about that a different day and then this will return you editor okay so this is kind of the basic setup we've just refactored it so that it's not sandbox but it's you know hazel editor now this is supposed to push the editor layer which is called sandbox 2d so again I'll just rename this to the editor layer will remove hazel from here and wrap this in the hazel and name space alright and again our goal right now is just to recreate what we had in the last episode so we're gonna leave everything intact we're just changing it to editor layer and I will also fix up a lot of these things we're not gonna have this stuff here realistically I hope that what we were using by the way I might be fairly stupid here but I I hope that what we were using was sandbox 2d and on example okay good because otherwise I've taken the wrong layer and it might have been broken and that would not have been a good time okay no Hazel's here there's a few more left I'll get rid of Thor's and that looks pretty good let's go to the CPP file we'll change this to be editor layout we probably want like we might want a precompiled header as well in the future but I won't do that today and then we have so sandbox 2d I'm just going to find her place I'm up sturdy to edit Leia in the current documents all day to do all of that at once done that's it I think everything looks like it compiles let's compile has a letter so make sure everything compiles and links successfully well I have some coffee beautiful let's run it okay a little bit of a crash probably because of assets non-existing if I had to guess OpenGL shader that's also something we should probably test against things like I'm missing assets let's grab the sandbox assets paste them into hazel editor and we're on that again okay we're all good and well basically where we were last time but now this is the hazel editor and in fact I don't know if there's a way to rename it from hazel engine to like something else because I think the application we do window create and I think the default window prop says that it's hazel engine so I think we can if we how about we do this as well I think to make this happen to luck isn't to give it a name we can create a window with window crops but application of the moment is was blocking else because application we don't have an application name so as a little quick thing for now we'll say name right because it's pretty reasonable when you're creating your application you should be able to give us a name and then what this will do all of this will do really is yeah by default I won't require a name but what I will say is that if a name has been given I don't know if I actually want to have a different application maybe just hazel engine or maybe even hazel app can be a default name I don't like to have too many defaults going on and unfortunately we kind of have this default title and then we have hazel app and it's kind of all over the place but anyway let's go back here and then to create that window props and I know I keep jumping back and forth and for that I apologize so we need title let's get rid of these unsigned ants I don't use that both typing in Russian accidentally as usual you end 32t will keep and then and I keep I really mean change will change this to you and 32 T's because that's basically what we use everywhere now not a big fan of you at unsigned int so anymore 1280 by 720 and title is hazel engine and we have a default within Heinz so technically we can just probably say we want window props name that should work okay and now if I run this again but we go to Hazel editor app and when we actually make this application we actually say application and then we give it a name such as hazel editor we can now give our application a name we should also be able to give it width and height and all that stuff but like initializing an application and setting it up isn't is a little bit more evolved than just like passing in some integers that are the width in the height of the app like that's something that you do if you're just making out a little bit sandbox roll test but if you you know if you've got a whole engine you know you don't have like a constructor that takes in a width and a height for your game that's a bit weird because it's dependent on a lot of on a lot of things it's not usually it's not programmed in you can definitely have like a default width and height but a lot of that's dependent on property is a lot of us depending on how you left at last so in other words if you used the editor and then you maximized and then you closed it you probably expect it to come back maximized not at the same size every single time so there's a few things to consider there as well that's largely it if we go back to sandbox the other thing I I said that I wanted to do was actually just basically get rid of the docking here and you know revert it to not be a dock space so if I get rid of all of this and and is that it oh we have the frame buffers I'll get rid of the frame buffer cuz we don't need that inside sandbox they start at the moment sandbox is going to become our runtime test so the idea is we create a game with hazel editor which will basically create a whole bunch of game data and then sandbox is going to be the application that loads that game daughter in and also might have a bunch of other zvp files that dupes and things if you want to do that and that's gonna that's gonna be the wrong time so sandbox is like our game test but hazel editor is like the actual like it's action it's an actual hazel tool that you use to build applications or games so that's the deal with those two things I think that's I think that's it yeah well we won't create frame buffer obviously let's switch to this project and run it I just have a little custom shortcut ctrl shift P it whatever file you have there it if you hit ctrl shift P it makes that we still got this it makes that the sava project okay so once get rid of that maybe so we have our check a book texture let's get rid of that and the big the big like panel is just it's because we left at lodge last time okay that's it so we're back about we've got all our functionality back now if I go back to his letter to AB from children to P an f5 then we have hazel editor and this is like our editor where we have our dock space and I think everything is working pretty well so what we're gonna do next time is actually talk about getting the ayam GUI panel to be what we're gonna make a new I'm giel panel which is going to be our viewport and that's whatever size that panel is that's this that's gonna be the size of this thing we also have to fix things like scrolling because my scroll wheel doesn't work right now even those WASD actually does and I'm not I'm also it kind of looks flipped to me so I just realized that because WASD is making good see if you want to flip it back what on earth am i doing editor layout so I'm not sure why exactly is clipped probably because 0 0 0 like zero on the y-axis is probably the top and I'm going where as in you know I've been jealous at the bottom so I think these UVs are just a little bit messed up so the way that we can fix that so we've got UV 0 UV 1 okay 0 & 1 so that's just the min and Max so what we can do is change this so that our min instead of being 0 0 is 0 1 and our maths is 1 0 instead of 1 1 and that will basically flip the image because we're just changing the actual Y coordinates and this is just canceling diagnostic session thank you visual studio I should probably switch to like vim or something now the whole thing's not responding come on man just run my program all right there we go sorry did that flip it I mean it's kind of hard to tell isn't it which probably try and draw something I don't know if I flipped it or not it should have right because I did that which we were drawing some what am i doing you know I didn't flip it because I mean oh no I'm in the right thing I'm but I'm in this stupid right this is the mistake I made last time and like it was clear that I was stupid for doing this but anyway whatever okay there we go now at the image of slips because W actually makes the camera go up which is what we expect okay so that is that now scrolling doesn't work I imagine that's because the scrolling is being somehow sucked up by I am going maybe that Geritol the event is not being propagated really easy to figure out if that's the case because if we go to well if we go to event here this might be bad though but if I cuz I'm sure I'm gonna get many events and it doesn't look like I'm getting any events in there delay which is very strange so all the mouse events are not happening in editor layer for some reason that's odd that's something that we need to investigate next time so in summary next time what we're going to do is we're going to continue on with the whole dock space adventure obviously and we're going to basically take the I'm goanna we're gonna make a viewport one and we're gonna make that display our frame buffer for our scene and that way we're going to be able to have like adorable environment with panels everywhere and a viewport in the middle that you can drag off put into another monitor dock it wherever you want and do what you would expect with a level editor so I hope you guys enjoyed this video if you did please don't forget to hit the like button and help support this series and my channel on patreon.com for such the channel huge thank you to all the people supporting this don't forget that if you do become a patron you'll get access to weekly live streams from me developing hazel dev and all of the fun 3d stuff and like the editor workflows and basically stuff that eventually makes its way into this series here as well as access to that source code and like other exclusive content thank you guys for watching I will see you next time goodbye [Music] you [Music]
Info
Channel: The Cherno
Views: 28,773
Rating: undefined out of 5
Keywords: thecherno, thechernoproject, cherno, c++, programming, gamedev, game development, learn c++, c++ tutorial, game engine, how to make a game engine, game engine series, hazelnut, hazel editor
Id: Qbt-1rcSqZc
Channel Id: undefined
Length: 19min 37sec (1177 seconds)
Published: Thu Jun 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.