diff options
author | P. J. McDermott <pj@pehjota.net> | 2021-03-18 06:54:03 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2021-03-18 07:10:58 (EDT) |
commit | 184c72b79e756a2eeefe56b74dfdb40300701cca (patch) | |
tree | c32742cf80056bf8a16d3d7da5c6ee9ebbb29b84 | |
parent | 47ce125aa2b1104711f8ed9bd757ff191b6f1e42 (diff) | |
download | dodge-balls-184c72b79e756a2eeefe56b74dfdb40300701cca.zip dodge-balls-184c72b79e756a2eeefe56b74dfdb40300701cca.tar.gz dodge-balls-184c72b79e756a2eeefe56b74dfdb40300701cca.tar.bz2 |
main: Initialize and quit SDL and SDL_ttf
-rw-r--r-- | src/main.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -17,11 +17,14 @@ * along with Dodge Balls. If not, see <http://www.gnu.org/licenses/>. */ +#include <SDL.h> +#include <SDL_ttf.h> #include <libgen.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "game.h" +#include "output.h" int main(int argc, char *argv[]) @@ -43,6 +46,16 @@ main(int argc, char *argv[]) } free(program_dir); + /* Initialize SDL libraries */ + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + db_err("Failed to initialize SDL (%s)", SDL_GetError()); + return EXIT_FAILURE; + } + if (TTF_Init() < 0) { + db_err("Failed to initialize SDL_ttf (%s)", TTF_GetError()); + return EXIT_FAILURE; + } + /* Find games */ n = db_games_find(games_dir, &games); if (n > 0) { @@ -55,5 +68,9 @@ main(int argc, char *argv[]) free(games); } + /* Quit SDL libraries */ + TTF_Quit(); + SDL_Quit(); + return EXIT_SUCCESS; } |