SDL_Tests

Exemplos simples para o uso da libreria grafica SDL
Log | Files | Refs | README

xanela.c (782B)


      1 #include <stdio.h>
      2 #include <SDL2/SDL.h>
      3 
      4 SDL_Renderer* rend;
      5 SDL_Window* win;
      6 
      7 int eventos(){
      8     SDL_Event e;
      9     while (SDL_PollEvent(&e) != 0)
     10         switch (e.type) {
     11             case SDL_QUIT:
     12                 printf("Pechase\n");
     13                 return 1;
     14         }
     15     return 0;
     16 }
     17 
     18 int debuxar(){
     19     SDL_RenderClear(rend);
     20     SDL_RenderPresent(rend);
     21     return 0;
     22 }
     23 
     24 
     25 int main(){
     26     SDL_Init(SDL_INIT_VIDEO);
     27     win = SDL_CreateWindow("Xogo",
     28         SDL_WINDOWPOS_CENTERED,
     29         SDL_WINDOWPOS_CENTERED,
     30         200, 150, 0);
     31 
     32     Uint32 render_flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC;
     33     rend = SDL_CreateRenderer(win, -1, render_flags);
     34 
     35     for(;;) {
     36         if ( eventos() == 1 )
     37             break;
     38         debuxar();
     39     }
     40     return 0;
     41 }