Advertisement
Guest User

Untitled

a guest
May 5th, 2014
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.13 KB | None | 0 0
  1. #include <SDL/SDL.h>
  2. #include <libconfig.h>
  3.  
  4. int main (int argc, char *argv[])
  5. {
  6.     printf ("This is my simple renderer version %i.%i\n", 1,1);
  7.     if (argc != 2)
  8.     {
  9.         fprintf (stderr, "Usage: demo config\n");
  10.         exit (1);
  11.     }
  12.  
  13.     config_t cfg;
  14.     config_init (&cfg);
  15.     config_read_file (&cfg, argv[1]);
  16.     config_destroy (&cfg);
  17.  
  18.     if (SDL_Init (SDL_INIT_VIDEO) != 0)
  19.     {
  20.         fprintf(stderr, "Cannot init SDL\n");
  21.         exit (1);
  22.     }
  23.  
  24. //    SDL_EnableUNICODE(SDL_ENABLE);
  25.  
  26.     SDL_Surface *screen = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE);
  27.     if (screen == NULL)
  28.     {
  29.         fprintf(stderr, "Cannot init screen\n");
  30.         exit (1);
  31.     }
  32.  
  33.     SDL_Rect rect;
  34.     rect.w = 800;
  35.     rect.h = 600;
  36.     SDL_FillRect (screen, &rect, SDL_MapRGB (screen->format, 255,255,255));
  37.     SDL_Flip (screen);
  38.  
  39.     while (1)
  40.     {
  41.         SDL_Event event;
  42.         if (SDL_WaitEvent(&event))
  43.         {
  44.             switch (event.type) {
  45.             case SDL_QUIT:
  46.                 SDL_Quit();
  47.                 exit(0);
  48.             }
  49.            
  50.         }
  51.     }
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement