Skip to content

Instantly share code, notes, and snippets.

@SharkyRawr
Created January 28, 2015 15:50
Show Gist options
  • Save SharkyRawr/16971345f6f7cdb7af82 to your computer and use it in GitHub Desktop.
Save SharkyRawr/16971345f6f7cdb7af82 to your computer and use it in GitHub Desktop.
bool quit = false;
SDL_Event e;
Uint32 tick = SDL_GetTicks(), lastTick = tick;
while (!quit) {
SDL_SetRenderDrawColor(ren, 0, 0, 0, 255);
SDL_RenderClear(ren);
// Processing, drawing, advance time, etc...
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT)
quit = true;
if (e.type == SDL_KEYDOWN) {
switch (e.key.keysym.sym) {
case SDLK_ESCAPE:
{
quit = true;
break;
}
}
}
SDL_RenderPresent(ren);
// Delays for fake-vsync, etc...
}
SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
SDL_Quit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment