O'Reilly logo

SDL Game Development by Shaun Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hello SDL

We now have an empty project, which links to the SDL library, so it is time to start our SDL development. Click on Source Files and use the keyboard shortcut Ctrl + Shift + A to add a new item. Create a C++ file called main.cpp. After creating this file, copy the following code into the source file:

#include<SDL.h> SDL_Window* g_pWindow = 0; SDL_Renderer* g_pRenderer = 0; int main(int argc, char* args[]) { // initialize SDL if(SDL_Init(SDL_INIT_EVERYTHING) >= 0) { // if succeeded create our window g_pWindow = SDL_CreateWindow("Chapter 1: Setting up SDL", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN); // if the window creation succeeded create our renderer if(g_pWindow != 0) { g_pRenderer = SDL_CreateRenderer(g_pWindow, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required