Advertisement
Guest User

Untitled

a guest
Jun 9th, 2015
221
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SDL2/SDL.h>
  2. #include <stdio.h>
  3.  
  4. int main (int argc, char *argv[])
  5. {
  6. SDL_DisplayMode videomode;
  7. SDL_Window *window;
  8. SDL_Renderer *renderer;
  9. SDL_Event event;
  10.  
  11. int running = 0;
  12.  
  13. if (SDL_Init (SDL_INIT_VIDEO) != 0)
  14. {
  15. fprintf (stderr, "\nError initialising SDL video: %s\n", SDL_GetError ());
  16. return 1;
  17. }
  18.  
  19. if (SDL_GetCurrentDisplayMode (0, &videomode) != 0)
  20. {
  21. fprintf (stderr, "Error getting current display mode: %s\n", SDL_GetError ());
  22. return 1;
  23. }
  24.  
  25. //BUG if I use SDL_WINDOW_MAXIMIZED flag?
  26. window = SDL_CreateWindow("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, videomode.w, videomode.h, SDL_WINDOW_MAXIMIZED);
  27.  
  28. if (window == NULL)
  29. {
  30. fprintf (stderr, "Error creating window: %s\n", SDL_GetError());
  31. return 1;
  32. }
  33.  
  34. renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
  35.  
  36. if (renderer == NULL)
  37. {
  38. fprintf (stderr, "Error creating software renderer: %s\n", SDL_GetError());
  39. return 1;
  40. }
  41.  
  42. running = 1;
  43. while (running)
  44. {
  45. while (SDL_PollEvent (&event))
  46. {
  47. switch (event.type)
  48. {
  49. case SDL_QUIT:
  50. running = 0;
  51. break;
  52.  
  53. case SDL_KEYDOWN:
  54. if (event.key.keysym.sym == SDLK_ESCAPE)
  55. running = 0;
  56. break;
  57. }
  58. }
  59.  
  60. SDL_RenderClear (renderer);
  61. SDL_RenderPresent (renderer);
  62. }
  63. SDL_Quit ();
  64. }
Advertisement
RAW Paste Data Copied
Advertisement