 Hello everybody, and how are you doing? Welcome to a new tutorial series, and I'm trying to get underway SDL the simple direct media layer at least I think that's the acronym I sure as hell hope it is or also I'm gonna make a fool of myself right at the beginning of the video But yes, this is the the point of this new tutorial series. We're gonna be working in C++ I've been trying to get some videos out on that language moving away from Python moving away from batch and all these other Things but I want to buckle down and focus on C++ the hardcore strong language and See what cool stuff we can do with it. So the best way to approach this is to look at SDL So I have my terminal open right here. You can see the active window I'm in my C work directory, and that's where I've been typically for I'm doing the C++ stuff And I'm gonna make a new directory and call it SDL now when I get in there What I'm going to do is I'm going to check out How we can install SDL and I'm running Linux right now But if you need to know more information about SDL or that sort of thing you can go online Now when you go online the URL for the SDL library is www.libsdl.org You can't see my url bar So url bar or my address bar in this case But that's exactly what I have typed in and this is the home page at the moment The site may have changed by the time you're viewing this video. I don't honestly know but yes, SDL The simple direct me later is a cross-platform development library designed to provide low-level access to audio keyboard mouse Joystick and graphics hardware via open jail and direct 3d. It's used by video playback software Emulators in popular games including valves award-winning catalog and many humble bundle games You can see on the side here It kind of advertises some of the games that have been made with SDL You can refresh this over and over and over again to see some really cool stuff Dynamite Jack FTL faster than light Oot tiny and big. I know I saw amnesia on the dark descendant here at some point There are plenty of really awesome things that are made with SDL. It's a super cool library. So Let's go ahead and keep looking on here. You'll notice down over on the left There are the download links and you'll notice there are two versions of SDL SDL 2.0 and SDL 1.2 now years ago when I was first playing and tinkering and learning all about SDL I'd been using 1.2. So that's kind of where my background actually lies I'm gonna go ahead and take a few risks in this series I am going to venture into 2.0 without having played with it yet But I'm sure reading through the documentation and learning as we go along We can actually get something really really cool here with SDL 2.0 So that is what I'm going to use. You'll actually notice at the top This is the new current and stable version of SDL SDL version 2.2 2.0.2, sorry and that's what we're gonna be using if we go over to that download link It'll send us to the same place this banner sent us to and this is where we can download it You can find the source code. You can find Windows binaries You can use it for Linux and that sort of thing now for Linux You can have to contact your distribution maintainer for updates and that sort of thing And you have to do the same for the development libraries, which is what we want So, I kind of know in Ubuntu anyway, my package manager is aptitude or apgett Now, the way that we work with apgett is we use sudo, we have to be root And to search for libraries, you actually have to use apt cache or apt cache I think And then we search And I'm going to search for Lib SDL for the SDL library. You can see there's a bunch of stuff that shows up And I'm actually going to pipe this into less so I can look through it There is the development library for version 1.2 simple direct media layer development files SDL and There's another one way down here. I believe if we keep scrolling down Ba-ba-ba-ba-ba Lib SDL 2 dash dev simple direct media development layers for version 2.0 Point 2 and stuff. So I'm gonna go ahead and install that sudo apt get install Lib SDL 2 dash dev I'm gonna hit yes. I do want to install this junk. It's gonna go ahead and install that and Cool once it's done. We should be able to write some code now Okay, this looks like it's just about done here. I Want my prompt to hurry up and get here I'll just I'll just let this go. Let's go back to the website and let's go over into documentation let's look at the wiki and Okay, now it's explaining what simple direct media layer what it is SDL This is everything that we just kind of read over on the left-hand side. That's where we want to be checking out let's go check out the API by category and You can of course look at the introduction that kind of shows you more stuff What can else to yell do Migrating from version 1.2 to 2.0 it shows you where it runs on that sort of thing but Let's start over It can also show you some tutorials on getting started in that sort of thing But I'm gonna start anyway over in the API by category And let's look at the basics initialization and shutdown We want to know how to actually do this sort of thing Okay, good. It looks like it's done installing So now let's say to begin using Sdl in your program You must call Sdl init before anything else the role of Sdl init is to properly initialize the Sdl library and start each of the Various subsystems required as part of the call Typically, you can be using Sdl initialize video. You want to use a pipe if you want to use multiple Sdl init audio Those are the defaults I think there's also another one Sdl initialize everything, which is what we'll typically use You can see by clicking on any of these what more you can do. I wonder if they still use version I wonder if they still use everything. Yeah, they do Okay, I didn't know if they still did for version 2.0 and You need to shut down once you're done running the program with Sdl quit Sdl quit should be called before an Sdl application exits to safely shut down all subsystems including the default ones So we typically always have to include that. Let's hop over to my text editor I'm using sublime text and we know we have to include Actually, I'll save a new file as this. Let's go into C work C work Sdl I'll call mine zero zero one Initialize initialization Dot CPP Okay, and now that we have the file saved we actually include Sdl by using two Quotation marks here and that's been typing in sorry acronym Sdl and Dot H to include the header file. Okay Now I am going to use the namespace standard even though we're not really going to be using it in this video I am going to include arguments just for good practice We can do that with int arc C and the character array for arc V argument values We get our code block ready I'm just going to return zero for good practice and like the documentation said it we use Sdl underscore initialize to initialize the program and Sdl library now when you're working with Sdl You're typically going to be running functions that have this kind of naming conventions They have the acronym Sdl followed by an underscore and then camel case with the rest of the name of the function You could have Sdl underscore like set video mode And you'll notice that these words are all separated by the capital letter of the other word Okay, now for Sdl initialize we want to pass in Sdl initialize everything This is a flag or kind of a constant that we'll be using so that's why everything is capitalized And again, you saw that in the documentation So that works just fine for us now. Let's go down to Sdl underscore quit and that just kind of Safely ends the program for us just like it said in the documentation Okay, let's hop on over to our terminal and go ahead and compile this g plus plus filenames your zero initialization dot cpp and the way that you kind of link or load Sdl libraries kind of simply in in Ubuntu or any other Linux distribution is you use your back ticks and bash So you include the output of another command and the command that we're going to use is package config PKG Dash config if that's not installed on your system, you can go ahead and install it I believe that should be pretty simple so to app get install just like beforehand package config and we want dash dash C flags for the compiler flags and a dash dash libs for the libraries and then the name of this library or package in this case is Sdl to Now when we run this We get a compiled it works just fine for us if we run a dot out nothing happens Well, that's pretty okay because we didn't tell our program to do anything the code literally initializes sdl And then it quits it's not doing anything So in the next video, we're actually going to have this do something. Let's have it display a window or display something on the screen Thanks guys. Thank you for watching. Thank you. I hope you enjoyed this tutorial This has a lot of potential for us and we're gonna be doing some really cool stuff with sdl very very soon