sav

Sorting Algorithms Visualized
Index Commits Files Refs README LICENSE
sdl_extra.c (721B)
   1 #include "sdl_extra.h"
   2 
   3 status_t SDL_setup(SDL_Window **win, SDL_Renderer **rend) {
   4     if (SDL_Init(SDL_INIT_VIDEO) != 0)
   5         return ERROR_SDL_INIT;
   6 
   7     *win = SDL_CreateWindow(
   8         WIN_TITLE,
   9         SDL_WINDOWPOS_CENTERED,
  10         SDL_WINDOWPOS_CENTERED,
  11         800,
  12         600,
  13         SDL_WINDOW_RESIZABLE
  14     );
  15 
  16     *rend = SDL_CreateRenderer(*win, -1, SDL_RENDERER_ACCELERATED);
  17 
  18     if ((*win == NULL) || (*rend == NULL))
  19         return ERROR_NULL_POINTER;
  20 
  21     if(TTF_Init() == -1)
  22         return ERROR_SDL_FONT_INIT;
  23 
  24     return OK;
  25 }
  26 
  27 status_t SDL_cleanup(SDL_Window *win, SDL_Renderer *rend) {
  28     if((win == NULL) || (rend == NULL))
  29         return ERROR_NULL_POINTER;
  30 
  31     TTF_Quit();
  32     SDL_DestroyRenderer(rend);
  33     SDL_DestroyWindow(win);
  34     SDL_Quit();
  35     return OK;
  36 }