comparison src/system_sdl.c @ 16:ae58e7c3c328

Poll events regularly to avoid unresponsive app warnings. Handle quit event
author Michael Pavone <pavone@retrodev.com>
date Sun, 27 Mar 2016 21:42:10 -0700
parents c8a0dbd7752c
children 41ec033ef8c3
comparison
equal deleted inserted replaced
15:c8a0dbd7752c 16:ae58e7c3c328
1 #include <SDL.h> 1 #include <SDL.h>
2 #include <stdint.h> 2 #include <stdint.h>
3 #include <stdlib.h>
3 4
4 5
5 SDL_Window *window; 6 SDL_Window *window;
6 SDL_Renderer *renderer; 7 SDL_Renderer *renderer;
7 SDL_Texture *texture; 8 SDL_Texture *texture;
47 SDL_UnlockTexture(texture); 48 SDL_UnlockTexture(texture);
48 SDL_RenderCopy(renderer, texture, NULL, NULL); 49 SDL_RenderCopy(renderer, texture, NULL, NULL);
49 SDL_RenderPresent(renderer); 50 SDL_RenderPresent(renderer);
50 } 51 }
51 52
53 void system_poll_events()
54 {
55 SDL_Event event;
56 while(SDL_PollEvent(&event))
57 {
58 switch (event.type)
59 {
60 case SDL_QUIT:
61 exit(0);
62 break;
63 }
64 }
65 }
66