Created
April 19, 2015 17:52
-
-
Save mazurio/5092dc53bd4a4db956a1 to your computer and use it in GitHub Desktop.
Basic SDL2 Template
This file contains hidden or 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 <iostream> | |
#include <SDL.h> | |
using namespace std; | |
int main() { | |
if(SDL_Init(SDL_INIT_VIDEO) != 0) { | |
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl; | |
return 1; | |
} | |
SDL_Window *window = SDL_CreateWindow("r/gamedev", 100, 100, 640, 480, SDL_WINDOW_SHOWN); | |
if(window == nullptr) { | |
std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl; | |
SDL_Quit(); | |
return 1; | |
} | |
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); | |
if(renderer == nullptr) { | |
std::cout << "SDL_CreateRenderer Error: " << SDL_GetError() << std::endl; | |
SDL_DestroyWindow(window); | |
SDL_Quit(); | |
return 1; | |
} | |
SDL_Event event; | |
bool quit = false; | |
while(!quit) { | |
while(SDL_PollEvent(&event)) { | |
if(event.type == SDL_QUIT) { | |
quit = true; | |
} | |
} | |
SDL_RenderClear(renderer); | |
// renderTextures | |
SDL_RenderPresent(renderer); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment