Creating an Orthographic Camera | Game Engine series

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up guys my name is China welcome back to my Gammons and series so last time we took we talked about cameras and specifically the theory behind cameras and we planned all of that out you guys haven't seen that video definitely check it out I gave you guys a homework of trying to work this out yourself so hopefully you've done that if you haven't yet stop this video go back and watch that one really have a go because this series is all about trying to teach you guys how to make game engines and how they work and you're not gonna learn anything unless you actually do this stuff for yourself rather than just copying down what I do so definitely do that if you haven't already I want to thank all the patrons that made this series possible patreon home for Steph the Cherno is how you can support this series thank you so much to everyone who is supporting because that's what makes it stuff possible and I'm so grateful to all of you if you want videos early or you want access to super advanced source code that I've already written for this engine check out the link in the description pad on patreon and compos - there churner ok cameras we've done all the theory we know how they work let's just dive in and go into the sea bass class code and actually implement them ok so what we did two episodes ago is we created this render oh and we had render a begin scene we had render a submit we had render and scene we had all of this stuff and last episode we learned about all of the theory behind that so we don't even cover that again today we've done that in the last video which is awesome because it means that we know exactly what to do right so we need some kind of way first of all let's just deal with the camera side of things before we begin submitting that data to the renderer we need a camera right so what is the camera it's a view matrix and it's a projection matrix let's create some kind of class to store all of that since that renderer I'm going to add a new item it's gonna be a header file I'm gonna call it orthographic camera dot H I just wanna be really explicit about what kind of camera this is because we're also going to have of course a perspective camera or some kind of camera that we can move in the future as well so for now though this is just going to be an orthographic camera now that make things easier we are going to kind of wrap the creation of this so what you'll see me do in a minute and I just want to include GLM yeah what we're actually going to do is orthographic camera I mean I didn't have to call the file orthographic camera because I could have just put all the cameras in one file so that may have been a mistake but it's a cable tape that's the explicit for now when we create an orthographic camera and we get this constructor I don't want to take you in like a projection matrix we could write this could just be such as in generic camera class that it just like works directly on projection matrix interview matrix but I want to make this a bit more fun a bit more flexible so what we'll do is we'll just kind of take in a flirt that's going to be like our left essentially a flow that's going to be our right effort it's gonna be bottom and a flow that's gonna be top so this is exactly what a what an actual orthographic matrix wants write it once basically be bounce now an orthographic matrix is a matrix that instead of having like a frustum it has like because essentially just like a rectangular prism that is like it's a picture like a cube but it can be like a rectangle and we're defining kind of the left-right bottom top and there's also near and far bounds but typically for orthographic rendering like negative one for Nia and one for Phi is fine that's the defaults we're gonna use so we're not gonna actually take them in here if you wanted to you could make this a bit more powerful by providing that API but I'm not gonna bother because we don't really have a use case for it and this stuff is also somewhat temporary probably and will be rewritten okay so what do we actually need in terms of data well we know what we need in terms of data we need a map for that's our projection matrix and we need a map for this our view matrix okay now we actually need to keep track of where the camera is like the position of the camera and all that as well now we don't want to do this inside the view matrix because what we'll do is like once per frame essentially when we calculate where our camera is we want to count recalculate this view matrix this has to be the inverse of like the actual transformation matrix of the camera right that's what the view matrix is so we could have another matrix as actually the transformation matrix but of course you could just invert the inverted matrix to get your original matrix back so that's something we can do as well but essentially what I'm gonna do is I'm gonna keep track of the position by just using position right and in terms of the rotation I mean we could like keep track of the rotation either either by using like a back three of Euler angles or by using like a quaternion or something like that but you don't really rotate orthographic cameras you can rotate them like you know a long block the z-axis but if you want to do a rotation like that you can really just you know keep rotation as a float and that's gonna be fine and I'll initialize that to zero okay so there we have all the data that we could possibly need really for orthographic camera let's go ahead and provide some functions for everything we want so we want some kind of way to retrieve these matrices right so we can have a and I don't know like if you wanted to you could also cache the view projection matrix right so view projection matrix because you might not want you might you'd still need them separated but you might also be requesting this like very often and you don't want to do them the multiplication every time okay show yourself so you could do that again this is up to you because if you do that keep in mind you are using 64 more bytes of memory for this class I don't know usually it's not a problem though so we're gonna do that okay so we have position right so let's go ahead and make a set position function that will actually let us set the position so I'll take in a Const GLM BEC 3 which is going to be position and then I'm just gonna set M position to position so that lets us actually position the camera some way in the world right we'll also do a set rotation which will just be a flirt rotation so again this is going to be Z rotation rotation along the z axis because we don't really need any other rotation for anthropic camera because again this is basically a 2d camera picture it that way you didn't really rotate things along the X or the y axis fatuity that's gonna give you weird results that you probably don't want again obviously if there's a no this is an orthographic camera for like a 3d modeling application you're making then you still want to have you know XY & z rotation but in this particular scenario I'm picturing this as more of just an orthographic that specifically is for like 2d or 2d rendering that's why I'm doing it this way and in 2d we only have one axis anyway like I said we only have like two dimensions so therefore rotation along the z axis is all we can do okay so that's that I also want to have getters for this so float get position I'm sorry not float canciĆ³n back three reference get position const return and position right and then for rotation I'm going to do the same thing so float get rotation and oops this will be rotation Const on what I want to type today return M rotation okay wonderful so that looks like a pretty solid API to me now let's go ahead and actually create this now when we do this stuff see this is the thing when we do this stuff right set we've got set position obviously we don't have any ways of retrieving matrices by the way but when we do set position set rotation we probably need to update the actual view matrix unless we have some kind of update function which does that for us so this again is up to you if we're dealing with a camera that's responding to mouse movements you could implement an on update function or even hook this up to the event system and upon then you'll be recalculating your matrices but what I'm saying is at the moment our matrices do not get recalculated so what we need to do is create a function we could use on update again but I won't this example which will be recalculate the view matrix right and recalculate view matrix is basically going to be a function that we call whenever we set something so when we set rotation we want to recalculate the view matrix when we set position we want to recalculate the view matrix and we want to do this by the way after we set the value obviously so recalculate view matrix because here I'm still keeping this kind of in line and in one line because it's not that big of a deal but you know if you want to drop that into a CPP file or anything like that then that be totally fine and appropriate okay so this is what we've got we also need a way to retrieve these things so very easy I'm just gonna make a const GLM map for get projection matrix const which will return projection matrix right again you could make setters for this at this point you could really do whatever you want you could just make them you can make this a struct and have public fields instead there's no I don't know cameras are such a flexible you know API usually that you can cause VP matrix B projection matrix I like to be quite explicit especially because this series is about teaching you guys how this stuff works so we'll do that okay view projection matrix view matrix and projection matrix good everything looks pretty good to me now we can just make this constructor that actually ended up being the only thing in this file let's include age said PCH and orthographic camera namespace hazal go over here we'll get rid of this namespace what this is gonna do is actually make the matrix right so projection matrix is going to be basically a GLM orthographic or author I think it's called I forgot the actual I always forget where this actually is so it looks like it's in GLM extension like not four or something so I think it's GLM GTC matrix transform yep okay and then this takes left right and you can see this actually has a function that just takes bottom top I think they've also got one that takes near-far I'm not sure if we don't let's just see if we go to this and we look at what it does let's take a look try and take a look because this is quite hard to read of what it actually did for near and far so a little bit hard to see here but ortho for the place where it's supposed to use like near and far which for example is here you can see it just uses a default value of one so you could probably roll with that but I still I'm gonna provide negative one and one just so that we actually know what those values are and we're not relying kind of on GLM okay that's like finally enough that's pretty much it now we don't need to recalculate view matrix here at all oh we actually need that function not sure why visual assist didn't make it recalculate B matrix so this is something that happens after we changed the actual transform whether it be by setting the position or setting the rotation so what we need to do is calculate the actual matrix first and I'll show you guys the whole kind of code for this you could pop the optimizer but not doing everything every time but we're still going to do that just the you guys can see how it works so we have our transformation matrix now what is this gonna be so we're gonna take it's going to be position times rotation so the first step is to take the position and actually work out a translation matrix from that so that's just going to be GL GL M translate and all this stuff is in that matrix transform head on GL m translate we're going to take a base matrix which is gonna be the identity matrix like that and then we're going to translate it by a given vector now the vector is gonna be positioned right so that's how we kind of wind up with this then what we're going to do is multiply it by rotation so GLM rotate the math for that we're going to be rotating is just again an identity matrix and then the angle of which we're gonna rotate it is going to be rotation and then along which axis we're gonna rotate it is gonna be GL M vector 3 0 0 1 ok so there's that axis now few ways of writing this I mean what you could actually do technically speaking is because this takes in a base matrix you could actually break this up into two lines so that you do you know here transform equals rotate and then which major you've kind of rotate the transform matrix like this and you do all that I don't like doing it that way because it's just it's just to be confusing to read I don't really like it so what I usually end up doing is something like this right so and I've broken it up into two lines so that you guys can see it more clearly but basically we just we always use matte four here right and we just do translate in position that does the translation matrix then we multiplied ourselves manually by the rotation matrix I'll have to look in performance to see if it's actually better to just start with an actual matrix instead of identity when we create these matrices but to me this actually just makes more sense because we're basically just saying and I would love it if GLM didn't take in this matrix in the first place because then we could just do translate position and rotate you know a rotation like that and that would be beautiful but the API does that so that's just the way it is okay cool and you are probably supposed to use it by actually putting in the previous matrix here but again this kind of makes more sense mathematically I guess because you know starting from a other matrix and then not knowing about multiplication order or anything like that so that's how transform matrix that's beautiful but we need to invert it right so when we actually set our view matrix what we need to do is do GLM inverse transform so we're taking our transform matrix that were inverting it just like we talked about in that theory video in the last episode okay and that's it now we obviously obviously also need to calculate our view projection matrix which is going to be in this case G LM sorry just M projection matrix times M view matrix alright and that's how view projection matrix now I am I didn't write it as a view projection matrix not projection view matrix so I wrote a drawer textile or row major style even though it's like this so that might be a bit confusing but remember GM is column major because we're dealing with OpenGL and it's based on OpenGL so we need to do the multiplication this order not disorder if you do it the other way around it will not work correctly okay so this is not what you want okay cool I just don't do all that that should be pretty much it right so every time we change position or rotation we recalculate this whole matrix cool sounds good to me let's go ahead and try and use this so inside application we really should move all this stuff into sandbox app I probably should do that maybe in like a mid week episode because I don't really want to spend an episode on that anyway so we'll do include hazel renderer orthographic camera what I'll do is I'll pop over into the header file and I'm just gonna make and this doesn't have to be like this this doesn't have to be like a reference like a shared pointer or like a unique component or anything we can literally just make this kind of on the staff like that and then we'll have to in the constructor actually specify some values for it so we need the left and right near and far all of that stuff so we can just do minus 1 1 so we'll actually feed it the same values that are being used right now which is when we don't provide any kind of matrix okay so we have camera which provides all that stuff let's not even move it we don't need to move it by the way at the moment just so you know the view matrix so when we actually missed one thing that we should have done um and that is because if we request this view projection matrix right now it's gonna give us identity like it nothing Oh actually I don't even know I think by default it creates identity but it might not to be honest I don't know if it better create identity by default but anyway if it doesn't we can just set it just to be sure but anyway when you set out anyway because we need to set this view projection matrix right now to be projection times view right so this basically we need to run this code in the constructor as well so that we have a valid valid view projection matrix and just to make sure I will I can actually set view matrix to one like that which will create an identity matrix okay so that's done great beautiful so back an application I have a valid view projection matrix I need to get it and actually put it into my shader so how do I do that well I use something called a uniform and a uniform is basically just a per draw call kind of value that I can actually set to my shadow from the CPU side so from the c++ side in this case so the way that is accessed is we'll create one in the vertex shader it's just going to be written as uniform and then the type which is map four and then I like to use a yuan spa prefix just to let us know that it's in uniform this is going to be the view projection matrix okay just your projection is fine and then what we're gonna do is in GL position we're going to multiply this view projection by this position okay so again in DirectX you kind of do it the other way around and you'd probably you wouldn't use you probably using them all as well in actual cell but anyway in jail cell is just view projection times the switch in this case is our actual vertex position and obviously this is just for this shader so we'll copy that into the next shader as well because we have a blue shader as well so your projection and then B projection times and that's it and you can use uniforms anywhere you can just write uniform you know uniform Veck for color for example right and then you can take in an actual color into this and use that color say instead of this color to give that that blue the blue a rectangle any kind of color you want okay anyway we've got that now how do I actually set this though right so what we need is some way to set that uniform now we don't have that API inside chedda yet so let's go ahead and see how to set a 4x4 matrix so what we do is we'll just make a function I'm going to call this upload uniform mat for right this makes sense we will include GLM because we should know what it is and then what we want to do is take in a constant vlm math 4 which is going to be our matrix I'll just create an implementation from that now what we well the first thing we need to do is make sure that our program is actually bound now I'm gonna assume that you do that manually because if we want to upload a whole bunch of matrices or a whole bunch of uniforms we don't want to keep binding and every time so I'm gonna actually mandate that you actually bind a pro bind this program before you actually upload this matrix so this is just going to the upload part but basically we need to make sure that we like you know GL use program first and then we're gonna do GL uniform mate matrix for F V now F means it's float would be means is an array of floats because obviously a matrix is 16-foot so the first the first piece of information here we have is a location so where on earth is this matrix so to do that we need to retrieve the actual location now we've called a variable something we've called it v+ we've called it you view projection right so what we actually want to do is retrieve that and we can do that by calling GL and get uniform location okay what we do with this is we pass in the program which is M render ID and then we pass in an actual name so in this case it would be you you know production matrix obviously what I want to hard-code that so we're just taking name and name will be a Const STD string name and then we'll take into matrix as well so this name will copy that paste it into here this is gonna be name this gives us some kind of like result essentially it's gonna give us an int I believe and the int will just determine and if I go back to here I can see it gives us an int yep this int will determine whether or not this is what we're on is valid so because that's negative one it actually means that it doesn't exist and we just need to do name dot C string okay so that's our location let's assume that worked from now we at work probably next episode maybe we might take a look at uniforms in just a better way because this video is about implementing the camera we take an account so this is not how many floats for giving us how many matrices were giving we're giving one matrix so we write 1 transpose is whether or not we should transpose the matrix so if you were in row major ordering because you were using like a row major math library or like a DirectX maps or something like that like that you just need to transpose your matrix you would just type in GL true and it would transpose it for you raising column major Maps already column major matrices so we just type in jail false umm and then finally this is a pointer to the value um numerous ways to retrieve this from GL but usually I use GL m value pointer MN matrix and that gives us back that gives us back an actual point and now you know what to use value point oh and you need to include it and I have no idea where it is GLM GGC maybe value pointer or or is it g TX value point I don't know where this thing is man okay so it's actually I googled it's GL m type point up so thanks anyway there we go okay and then we do that that's how we upload a uniform Malfoy into our shader so now that we know that what we can do is and we're not going to upload it here we're gonna actually upload it before we draw okay what we want to do is just to test this out Elise is once we bind our shader we want to upload upload a uniform mat for and this is gonna be our camera guess view projection matrix okay and then obviously we need to give it a name and what do we call our uniform u underscore view projection matrix so we just put that into the string like that and that's how we actually set that variable in our shader we're gonna do the same thing for this so shader and an upload uniform map for done now if we run this we should see hopefully the exact same result as before I know that we're binding the shader first here so let's go ahead and see what we get we actually got a ton of build errors so that's fantastic camera is unknown that's because I think we included camera into CPP file whereas we should have done that in here so we'll just leave that here try and build again and hopefully it worked this time all right and build was successful here's us running it and you can see we got the same result now that's great let's try and change this matrix and see if we actually achieved anything so back in our CPP file I'm gonna try to make this a lot bigger right so it's like negative 1 right now sure what I'm gonna do is actually make it bigger and if I make it bigger if I just open Photoshop here and just draw with the mouse um this was our current screen right this was negative 1 this was positive 1 what I'm gonna do is make it bigger right so what that's gonna do if I set it to negative 2 is suddenly it's gonna be like this big right what that actually means in practice is that my vertex positions which if we go back here for a second my vertex positions used to be like negative 0.5 to 0.5 for the triangle if my vertex positions were that right it means that this was 0 0 so this was like negative 0.5 the triangle looked like this right and that's awful but you kind of get the point the triangle looked like that or whatever I think it actually started like that if I make this negative too suddenly that negative 0.5 is actually going to be like more here so the triangle is gonna be like that maybe everything's gonna be smaller because I've made the left and right bounds and the top and bottom bounds of my screen a lot bigger so if I go over here into this and modify it so that is negative 2 to 2 and negative 2 to 2 on both X&Y everything should be smaller because what I've done is just made the bounds bigger so the camera can kind of see more in this scenario and you can see there we go everything's a lot smaller now one thing that I've hated since we've kind of started this is the actual aspect ratio of this right so obviously if we look in our actual code here you can see that we're defining a square right this is a square it's negative 0.75 to positive 0.75 in every axis it's a square but it's rendering as a rectangle why because the matrix of course our projection is from negative 2 to 2 or negative 1 to 1 in both of these however this window is not square if we make the window square like that I mean we haven't said that up properly but you can see it kind of gets it kind of looks right in the preview before we actually remember this so what we want to do is actually set this actual like projection matrix to be the same aspect ratio of our actual scene right now it doesn't have to be like you know in pixels or anything like that it just has to be the right aspect ratio now clearly we've made a window I think that's 1280 by 720 that's a 16:9 aspect ratio so what I actually could do is just do something like negative one point six two positive one point six on the x axis and then negative point nine two positive point nine on the y axis and now this obviously is gonna be 16:9 right so let's go ahead and try with this and we should get an actual square square and you can see that this square is now square now this triangle looks very tall now and not as nice but we're actually rendering a square which is pretty cool so I'm just gonna leave it at that now API wise when perfect right because what we're having to do like we've got the result we want 100% but you know begins teens not taking a camera like we kind of decided we would in the previous episode so what I'm gonna do is hop over here into the renderer and actually make this take in a camera now how we taking a camera again I did say that we can take in like a reference to a camera or we can copy the camera or we can do whatever I definitely don't want to copy the whole camera class because if we look at the whole camera class it's like for matrices have that like a three component vector on the floor so it's like four matrices plus a full component vector essentially that's too much like I don't want to copy all that data if anything we just need a copy projection matrix so what I could do is you can begin scene I could just take in essentially a reference to an orthographic camera it doesn't really matter where it comes from but I'm taking in a reference to it so it could be from a pointer from a shared pointer anywhere because what I kind of want to do in this case is maybe just copy that matrix right you'll see that will actually kind of do more than that there anyway that's kind of what I want to do fourth or rather camera I could just actually also have a shared pointer and then get a reference that in scene but as I mentioned that's not really the design we want to go for at least not right now so orthographic camera is gonna be inside a begin scene okay so what that means is that and I'll have to include this so include orthographic camera what that means is that when we begin scene now we have to actually submit a camera which is exactly what we want the next step is we need to also bind the appropriate shader and upload this uniform at fault what that means is that when we submit something for rendering now we need to be aware of what shader it should be rendered with right so what that means is that this function now needs to take in information about the material of this geometry right so basically in this case all we have is a shader right and the material is just a shader on a set of uniforms and that will be something stored in a mesh so whenever in other words in the future this will just take in basically a Const reference like a shared pointer right to an actual mesh I said references in like a ref counted object but basically it's just gonna take in like a reference to a mesh and that's it but right now we don't have materials obviously with meshes already kind of that so we just taking a vertex array and then we're actually going to take in a shader as well so const STD shared a pointer shader okay and that's going to be the shader with which we render so i'll copy this into here and i don't know if you want taking the trader first or the trade a second or whatever you want to do it's kind of up to you when we put shader over here this is temporary and anyway so i'm not putting too much thought into it but basically what we want to do here is actually bind the shader doesn't matter in opengl doesn't matter if you do it first a second and then we want to actually upload that camera but the cameras here and this whole class is static so we have no way of storing it so how is that going to work well again traditionally you need some kind of backing data that the renderer has we don't have anything like that at the moment you could if you wanted to so it's kind of up to you how you do this but basically what i'm gonna do is make a case i want to make a struct for the same data right and then this is going to have in this case a projection matrix so GLM matte for view projection matrix again and i'm gonna have a static scene data pointer now this is totally up to you how you want to do this this is like I don't know we're gonna revise this design in the future because we suddenly run into a renderer there's not a hundred percent static but needs to persist with the state so it's up to you how you end up doing that so now we're just gonna do it this way scene data is going to be basically something that's gonna live for the entire duration of our actual of our actual renderer right and we're only gonna have one of them so it's totally fine to just keep allocate that there and leave it as be so what happens here is when we begin a scene what I want to do is access scene data and set the view projection matrix the camera yet view projection matrix okay and that's kind of the same data and then finally over here after we bind this we want to upload that uniform mat for it's gonna be going into you a blue projection and it's going to be obtained out of your projection matrix okay let me just double check yeah it is your projection I thought I might have maybe possession matrix okay that's done all right okay that's as simple as it is to just set this up we need to take in a shader and we've taken a vertex array what I might do is actually I've decided that and I wanted to do that I know why I didn't but I actually do want to have the shadow first because we can't really like a vertex raise great we're submitting that but we need to know the shed is not more important I think than the actual geometry data you know way for this because the shader kind of specifies how we're rendering and then what were rendering so I just kind of like that way or order of things more okay so in here we submit the shader first so blue shader and then we submit the actual vertex array and then over here again we submit the shader and then the vertex array and then guess what this disappears this now does not need to be done so we have a begin scene we have two submissions and we have an end scene and that's it and it's gonna respond to our camera and everything's gonna be amazing so let's just run this code and see what we get okay and as you can see we get the same result as last time isn't that cool so that is basically it you can see that really all we do is we just create a camera with a particular orthographic projection now we didn't do step position or anything let's do that for fun so what I'll do is I'll set em camera I'll set the position yeah we should test that out for sure I'll set the position to be offset a bit so we don't want to go too far maybe 0.5 in both x and y right because if we go too far everything's gonna be off the bounds so let's just set our cameras position to 0.5 here and see what happens okay and as you can see we moved the camera now where do we move the camera when we move the camera point five point five so we move the camera right and up and you can see that this has moved down right down and left which is the opposite so obviously our inverting is working correctly and then finally what I want to do is actually set the rotation so we'll say camera set rotation right and it might be better to do that without setting the position actually just so that it doesn't rotate somewhere else because if we rotate both and it's gonna be a bit off the screen but we all basically just wrote out everything 45 degrees and see what that gives us okay so it's giving us nothing which is quite strange so we should probably diagnose that first of all I very stupidly I think even consider the rotation in terms of whether it would be in radians or not obviously I think it will be in radians so we should actually cast this into radians and then we have our translation and our rotation so that should actually all be correct let's go ahead and try that out again and see what we get okay so yet again nothing that's always fun let's go ahead and try and debug this one of the first things I'm gonna do to debug it is actually trying to set the rotation to a pretty small value like 0.5 I also want to take a look at the actual camera API here to see that I'm actually setting everything correctly so yes rotations being set to rotation and I am in fact recalculating the view matrix so that's all correct yeah that's that's quite strange but if we set it to a low value we should see no we actually see nothing that is quite peculiar okay so let's just start by diagnosing all the numbers whenever something like this happens it's really important to actually dive in and see what the numbers that you're getting in your matrix are and this can be hard for some people who aren't too experienced with matrices but I should be fine so recalculate view matrix is where everything happens let's see what our serve our rotations 0.5 our position is okay our position is not set so I guess GLM doesn't actually initialize things like at all I think maybe I was under the impression that that would just get set to zero zero zero but it didn't so that's a bit of an issue this float of course we did actually set a zero so that's good but position doesn't get set to zero so that would be the issue so we need to make sure that we do that sir how come when we hit a position just make sure that I set that to zero I might be able to just do that or I cannot I'll just do that and now if I go back here again change this to be 45 instead to make it a bit better let's just launch this and now everything should just work I think okay and as you can see everything is on a 45 degree angle now we should be able to move the camera slightly as well with no issue at all it's important to test that both like translation and rotation actually works so we'll try and move it like maybe one or something one might be too much the 0.5 again we'll try and move at point 5 whoops make sure that we give this as a three component vector and it should just work okay so you can see that we've both rotated and translated our camera and everything seems to do working correctly of course is doing that the rotation still is correct it's not rotating around the new origin point it's doing it in the right order which is really important so there we go we've got rotation and we've got translation and we've got cameras a bit of homework for you guys if you want to do something yourselves is actually try and make this position and rotation stuff try and control the camera using like the WASD case or the arrow case or something like that so you can hook on into events and then set positions or rotations based on that so see if you couldn't do that for homework that would be quite a little good little exception exercise but summarize you can see how clean everything is we're now beginning a scene with a camera and then we're submitting everything they get the shader the shader uses the view projection matrix to actually set the camera data right obviously right now we're binding and setting shaders for everything so if I render a whole bunch of these with the same shader it's gonna set it every time so what we won't actually want to do obviously is when we submit we want to store the shader and the vertex array any other geometry in like a list and then kind of you know bash them together essentially but for now you can see that this kind of simple way of doing things works wonderfully so there we go that's pretty much all there is to say about cameras next time I do want to actually maybe expand a little bit on how shader uniforms work but it might not be really quite necessary I don't think I've I mean I haven't covered uniforms at all in the game engine series but they might not be necessary just yet I think what another better thing for us to explore potentially might be this whole model matrix thing so we'll see I'll still make my decision based on what I think is better but that is cameras okay I hope you guys enjoyed this video if you did you can hit that like button you can help support this series by going out at patreon icon for safe the churner if you haven't already huge thank you as always to everyone who helped support the series you can get the next video a week early and you also get access to the source code for hazel head the hazel development branch where I've done like a 3d scene with a PBR ender and a whole bunch of other really cool stuff animation is in there everything is really cool next time as I said maybe some graphics see things maybe the model matrix kind of stuff we'll see how this kind of ties in together because of it there's a lot of pathways or we could go down into to make this stuff happen but you can see that oh and I really want to have like a midweek episode probably to just move this stuff away from the application class obviously an entry our actual sandbox app so I'll probably do that as well anyway I'll see you guys next time goodbye [Music]
Info
Channel: The Cherno
Views: 25,769
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, orthographic camera, 2d camera, opengl
Id: NjKv-HWstxA
Channel Id: undefined
Length: 38min 27sec (2307 seconds)
Published: Sun Jul 07 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.