 How is it going everybody? Welcome back to another C++ SDL video tutorial. In the last video we did some pretty awesome thing, all we did honestly was just make the main event loop for our program. All that it did is it would test, it would check out this SDL event, and it would determine at every frame or at every second because we have this infinite loop while running, which is all the time in this case. It will repeatedly pull the event, and it will test if the event.type is equal to sdl.quit, or sdl.underscore.quit. And if it is, that means we close the X button, that means we press the X button, and we want to close the window. So running will equal false in this case, so we can end the loop and we will break out of this loop. So that's just fine for us. Then we destroy the window and quit the program. So in this tutorial I'm going to go ahead and save this file as something different here, 03 underscore window underscore functions.cpp. Cool. So this is pretty simple, and honestly this is just a bit more of an experimentation as to what we can do with our documentation. And looking at the cool functions that we can do with our program. So right now I've got the introduction page open. We want to be at the best place in the world, the API by category. We can get there over by the quick links over there. Now if you scroll down, you know we've been to initialization, shut down, that was really really easy. And then we kind of moved on to display and window management. And that's how we went ahead and created the window that we're using. Now notice we've got a boatload of other functions that we can use other than create window. In fact, we've got freaking, oh I don't know, 78 of them. That's awesome. So let's go ahead and browse through here. We've got some cool stuff. We're not really using anything other than create window and destroy window up top here. You notice we can do some things with the screensaver though. That might be fun to play around with. We've got some GL functions, and we haven't gotten to GL just yet. We've also got video drivers and stuff. We haven't moved into video drivers yet either. Ooh, we can get the window brightness and stuff. I haven't played with that. That might be interesting to look at. Get the brightness of the gamma correction for window. Man, we don't need to play with it. I mean, maybe another time. That's something you can do on your own. A lot of these are things that you should do on your own just to see what you can do. Ooh, get window position. That would be fascinating to look at. Get window size. That's pretty simple because we set that. Get window surface. Ooh, that's going to be crucial when we actually start to do more things with this. Let's keep that one in the back of our minds. Get window surface. That's a nice function. Get window title. We set that, but it might be good to kind of test for it later on. Obviously, of course, we can change it. Ooh, maximize window and minimize window. We can do those things. Hide window instead of invisible. Get the window management information. We can determine whether or not the screensaver is actually on, dude. And raise window and restore window in case we actually haven't minimized. We have a lot of control on this thing. This is super cool. And of course, we can set everything that we can get. Cool. Even message boxes, show message boxes. Dude. So let's go ahead and play with some of these things. I'm going to stop pretending like I'm impressed and let's actually program. Let's up over to our text editor. I'm going to code-fold some of these things here, code-fold. And I'm going to go ahead and create some new variables for us. I'm just going to declare them right now. I'm just going to say x, y, width, and height. Pretty simple. I don't know if we're actually going to end up using width and height, but I'll declare them just in case. And let's decide on the function that we want to use. Let's use get window position because that'd be kind of cool. Use this function to get the position of a window. All right. And well, the syntax or how we use it, this function doesn't return anything, which is weird because normally in Python or another language, you kind of expect it to return the coordinates, right? You just expect it to return x and y values. Well, STL and C++ typically works a little bit differently. Instead, we'll pass in variables that we want to be used. And those will actually be filled or flowed with the variables and the information that we will see this function actually gets for us. When it gets the window position, x, the variable that we pass in, will become the value of the Windows x position. And y will do the same thing. It will become the value of the Windows y position because we're passing in a reference to it. This function can accurately manipulate the data. So super duper cool. Yeah, see, a pointer filled in with the x coordinate of the window and the same thing with y. Let's go ahead and play with that. What if we were to test or what if we were to use this function all the time in our wow loop and repeatedly get the coordinates of this function? Let's check it out. If we use STL underscore get window position. See, it did ask for the window. Cool. That's already a pointer. So we don't have to do anything with that window. And we want the reference to x and y. Remember to end that line with the semicolon and then we'll go ahead and display what we're actually doing here. I'm just going to use a comma to separate these. And we'll use endel. Cool. Now let's go ahead to our terminal and compile this. I actually already have the line set up and pre-made for us. Run this program. Ooh, you see all those fancy numbers? I'm moving this window around. I keep moving around and the values keep changing. God, that's awesome. We're repeatedly getting the position on our monitor on my screen. You can see the position of the window. And that's how we can actually do things. I'm assuming it's seeing these at the top left of the window. It might be this pixel here. I don't honestly know. We can kind of determine whether or not we want to have the border on or not. I'm getting the negative values here. I'm so cool. Yeah, it looks like it is using it from the top left pixel on the screen, not from this border. Let's check it out with the borders off. I know it saw a function where we can manipulate that over in the documentation. Let's head back and let's see. Set window bordered. Yeah, dude. All right, cool. This just takes a Boolean value. Sdl false to remove border and Sdl true to add border. I wonder if it can use this regular C++ true and false. Let's find out. Let's go over to the very beginning of our code up here. Let's say Sdl.set window bordered. Pass in window. The variable that we've been using. And let's just use false for now. See if it will actually compile and use it with that. No, it won't. It has to be Sdl Boolean, not a C Boolean. So we can use Sdl false. Remember, we saw those flags in the online documentation. Remember, they are all capital letters because they're flags and constants. Let's check it out. Compile this, see if it works for us, and boom, it does. Oh, I don't think you're actually going to be able to see this. And I can't move it. Oh, shit. Can I close this window? God damn it. I don't think I can. Because I can't actually use the border. Damn it, I can't move it. I can't do anything with it. Well, you know that it exists because you're repeatedly getting the position of it. I might have to kill it though. Peek, kill, eat it out. Okay, cool. And now it ended. Oh, wow. Well, that was a fun experiment. You guys will have to trust me that it just turned off the border for me. I'll comment out that line. We'll see what more we can do with this. Check it out. We can set the window's position. We can set its title again. Yeah, let's reset its size. Actually, let's reset its title. SDL set window title window. And I'm sure this will just take a character array or a string. Subscribe, please. It's like I'm begging you. Compile this and it says subscribe, please. Cool. That's very simple. All it does is change the window title for us. I can comment that out as well. Let's set its... I wonder if we can resize it. Yeah, we can set the title. Set the size. Size. Let's use width and height. And I'll bring this line down, actually. And let's set width equal 100. And let's set height equal that as well. And the line there. I want to double check in the documentation and make sure that is the way it works for us. Yep, it just takes those two in regularly. Okay, cool. Now we'll head over to it. Check it out. Run the program. Oh, and we got a tiny little box here. That's awesome. Cool. What more can we do? I love just playing around. Set window position. Set window position would be kind of cool. What if we actually set it... All right. Let's set it repeatedly in this position so I can't actually move it. 1550 and 264. That's a good spot for it. Head on over to our text editor. You know what I'm going to do now? X, Y. Yeah, I'm just going to do this pretty explicitly. X is going to equal that 1550. And Y is going to equal that 264. That is what the values were, right? Yeah, cool. I'm glad I remembered that. I got some good short-term memory. And we're not going to resize it or anything. We will, however, set the window's position. And since we're not returning or retrieving the value in our variable, let's just use X and Y here. And I won't actually display out. Now, if we run this code, I wonder if my code, my program... Oh, oh, oh, oh no, oh no. Nope. Doesn't like that at all. Program crashed. All right. I'm going to end the video now. Thanks for watching, everybody.