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, ...
Get SDL Game Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.