From fc51174edbcb6f728e226bd961356099ac134185 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Thu, 18 Mar 2021 10:26:43 -0400 Subject: main: Create window, renderer, and texture --- (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 9f0a0a3..d64caae 100644 --- a/src/main.c +++ b/src/main.c @@ -32,6 +32,9 @@ main(int argc, char *argv[]) char *program_dir; const char *games_dir; const char *fonts_dir; + SDL_Window *window; + SDL_Renderer *renderer; + SDL_Texture *texture; struct db_game **games; int n; int i; @@ -58,6 +61,32 @@ main(int argc, char *argv[]) db_err("Failed to initialize SDL_ttf (%s)", TTF_GetError()); return EXIT_FAILURE; } + window = SDL_CreateWindow("Dodge Balls", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + 640, 480, 0); + if (window == NULL) { + db_err("Failed to create window (%s)", SDL_GetError()); + SDL_Quit(); + return EXIT_FAILURE; + } + renderer = SDL_CreateRenderer(window, -1, 0); + if (renderer == NULL) { + db_err("Failed to create renderer (%s)", SDL_GetError()); + SDL_DestroyWindow(window); + SDL_Quit(); + return EXIT_FAILURE; + } + texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, + SDL_TEXTUREACCESS_TARGET, 640, 480); + if (texture == NULL) { + db_err("Failed to create texture (%s)", SDL_GetError()); + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + SDL_Quit(); + return EXIT_FAILURE; + } + SDL_DisableScreenSaver(); /* Find games */ n = db_games_find(games_dir, &games); @@ -71,7 +100,16 @@ main(int argc, char *argv[]) free(games); } + SDL_SetRenderDrawColor(renderer, 0x7F, 0x7F, 0x7F, 0xFF); + SDL_RenderClear(renderer); + SDL_RenderPresent(renderer); + SDL_Delay(1000); + /* Quit SDL libraries */ + SDL_EnableScreenSaver(); + SDL_DestroyTexture(texture); + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); TTF_Quit(); SDL_Quit(); -- cgit v0.9.1