# SDL (Simple DirectMedia Layer)/Basics
## Getting started

In this section, we will show you how to initialise and shutdown SDL subsystems.

### Linking SDL2 libraries

The basic functions required for SDL2 is either in the <SDL/SDL.h> library or <SDL2/SDL.h> library depending on the operating system, hence the above source code uses

### main macro in Windows

When writing code for Windows machines, it is necessary to include
since SDL overwrites the main macro. According to SDL's FAQWindows:

### Initialising SDL subsystems

When using a SDL subsystem, you must always initialise it first. In the following if-statement, we initialise the SDL video subsystem with the flag SDL_INIT_VIDEO. If it succeeds, it returns 0, otherwise it returns a negative error code and will print information about the error using SDL_GetError through the stderr stream.
You can initialise multiple subsystems using the | operator:
All information about the SDL_Init function subsystems, and their flags can be found in the SDL Wiki's SDL_Init page.

### Shutting down SDL subsystems

To shut down the SDL subsystems, you must execute
However, this will only shut down the main subsystems; shutting down the TTF subsystem requires a different function

## Setting up on various operating systems
### Getting started in Windows

SDL (Simple DirectMedia Layer)/Basics/Getting started in Windows

### Getting started in macOS

SDL (Simple DirectMedia Layer)/Basics/Getting started in macOS

### Getting started in Linux

Install the development libraries of SDL from the official repositories of your Linux distribution.

#### Terminal

The argument -lSDL2 means after compiling sdl.c with gcc, the binary sdl, named using the -o argument, is linked to the SDL 2 runtime libraries.
NOTE: Linking the binary to SDL 1.2 libraries requires the -lSDL argument.
To continue using the terminal to build your source, you can use GNU Make, CMake or a plain Makefile.

#### Code::Blocks
## Creating a window

In this section, we will demonstrate how to create and destroy basic SDL windows. The following code will create a window called "SDL Example", 800 by 600 pixels in width and height respectively, and print it on the screen for 3000 miliseconds.

### Setting up data

In order to create the window, we need to specify its height and width. In this case we define the global constants using a macro. We'll make the width 800 pixels long and the height 600 pixels high.
In this program, we will have to pause the SDL subsystems to let the window stay open. We'll define the delay to be 3000 milliseconds.
In C, it's a good idea to initialise your variables first in order to understand when and how they are being used. In this case, we initialise a SDL_Window pointer called window. In SDL, almost all objects are initialised as pointers.

### Creating the window

In order to create the window, we need to use the SDL_CreateWindow function and set some parameters too.
You can learn more about SDL_CreateWindow in the SDL Wiki.

### Using SDL_Delay

In the example code, we used the function SDL_Delay in order to pause the SDL subsystems for a variable amount of time in milliseconds and allow the window to be shown on the screen whilst it is open. In this case, the pause is defined with the DELAY macro as being 3000 milliseconds.
You can learn more about SDL_Delay in the SDL Wiki.

### Destroying the window

In order to close the window and free memory, we must destroy the window. Destroying window is much simpler than creating it.
You can learn more about SDL_DestroyWindow in the SDL Wiki.