Skip to content

Instantly share code, notes, and snippets.

@southwolf
Last active August 29, 2015 14:03
Show Gist options
  • Save southwolf/c8974c14d84f565caa52 to your computer and use it in GitHub Desktop.
Save southwolf/c8974c14d84f565caa52 to your computer and use it in GitHub Desktop.
SDL Event Processing
while (!done)
{
if (SDL_WaitEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
view.interrupt();
decode.interrupt();
done = 1;
break;
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_RESIZED)
{
SDL_RenderSetViewport(renderer, NULL);
display_rect.w = event.window.data1;
display_rect.h = event.window.data2;
}
if (event.window.event == SDL_WINDOWEVENT_CLOSE)
{
view.interrupt();
decode.interrupt();
done = 1;
}
break;
case SDL_KEYDOWN:
if ((event.key.keysym.sym == SDLK_ESCAPE) || (event.key.keysym.sym == SDLK_q))
{
// Quit
view.interrupt();
decode.interrupt();
done = 1;
}
break;
default:
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment