Created
June 21, 2018 19:41
-
-
Save uzername/ed695d56d64a2da6f4eb9cbf6f1ca14a to your computer and use it in GitHub Desktop.
crude sdl2 code
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 <iostream> | |
#include <SDL.h> | |
#include "res_path.h" | |
int main(int, char**) { | |
if (SDL_Init(SDL_INIT_VIDEO) != 0) { | |
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl; | |
return 1; | |
} | |
else { | |
std::cout << "SDL_Init done"; | |
} | |
SDL_Window *win = SDL_CreateWindow("Hello World!", 100, 100, 640, 480, SDL_WINDOW_SHOWN); | |
if (win == nullptr) { | |
std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl; | |
SDL_Quit(); | |
return 1; | |
} | |
SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); | |
if (ren == nullptr) { | |
SDL_DestroyWindow(win); | |
std::cout << "SDL_CreateRenderer Error: " << SDL_GetError() << std::endl; | |
SDL_Quit(); | |
return 1; | |
} | |
SDL_Event Event; | |
bool Running = true; | |
while (Running) { | |
while (SDL_PollEvent(&Event)) { | |
if (Event.type == SDL_QUIT) { | |
Running = false; | |
} | |
} | |
} | |
SDL_DestroyRenderer(ren); | |
SDL_DestroyWindow(win); | |
SDL_Quit(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment