Last active
February 16, 2019 17:16
-
-
Save maavelar5/5324747cd70a28cd982b0cc543682f78 to your computer and use it in GitHub Desktop.
SDL2 + C++ Creating a window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SDL2/SDL.h> | |
int main (int argc , char **argv) | |
{ | |
SDL_Window* window = nullptr; | |
// This initializes the SDL library | |
SDL_Init( SDL_INIT_VIDEO ); | |
// SDL_CreateWindow ( title , x , y , w , h , flags ); | |
window = SDL_CreateWindow( "My SDL2 window", | |
SDL_WINDOWPOS_CENTERED, | |
SDL_WINDOWPOS_CENTERED, | |
500, | |
500, | |
SDL_WINDOW_SHOWN ); | |
// Wel'll wait 2 seconds before exiting the program | |
SDL_Delay(2000); | |
// This routine cleans up all initialized systems => SDL_Init( flags ); | |
SDL_Quit(); | |
return 0; | |
} | |
/** | |
Compilation + Exec command | |
Linux & MacOS brew | |
g++ -lSDL2 main.cpp -o main; ./main | |
MacOS framework | |
g++ -I/Library/Frameworks/SDL2.framework/Headers -framework SDL2 main.cpp -o main; ./main | |
Windows | |
g++ -w -Wl,-subsystem,windows -lmingw32 -lSDL2main -lSDL2 main.cpp -o main.exe; main.exe | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment