From d34860bce761e58c1edc62c7f3dc03f47589d0ba Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Mon, 14 Jan 2019 15:42:54 -0500 Subject: refactor main.c, add log-renderer-info.[hc] --- src/sdl/main.c | 69 ++++++---------------------------------------------------- 1 file changed, 7 insertions(+), 62 deletions(-) (limited to 'src/sdl/main.c') diff --git a/src/sdl/main.c b/src/sdl/main.c index fb0f2e0..43dcdcc 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -11,9 +11,10 @@ #include "warp-buf.h" #include "sprites.h" #include "draw.h" +#include "log-renderer-info.h" static void -draw_moves( +log_moves( const sok_ctx_t * const ctx, const size_t skip_moves ) { @@ -31,62 +32,6 @@ draw_moves( SDL_Log("Solution (%zu moves): %s", ctx->num_moves - skip_moves, buf); } -static void -log_renderer_info( - SDL_Renderer * const renderer -) { - SDL_RendererInfo info; - - // get renderer info - if (SDL_GetRendererInfo(renderer, &info)) { - die("SDL_GetRendererInfo(): %s", SDL_GetError()); - } - - // log renderer info - SDL_Log( - "renderer:\n" - " name = \"%s\"\n" - " flags = %u%s%s%s%s\n" - " num_texture_formats = %u\n" - " max_texture_width = %d\n" - " max_texture_height = %d", - info.name, - info.flags, - info.flags & SDL_RENDERER_SOFTWARE ? ", software" : "", - info.flags & SDL_RENDERER_ACCELERATED ? ", accelerated" : "", - info.flags & SDL_RENDERER_PRESENTVSYNC ? ", presentvsync" : "", - info.flags & SDL_RENDERER_TARGETTEXTURE ? ", targettexture" : "", - info.num_texture_formats, - info.max_texture_width, - info.max_texture_height - ); -} - -#if 0 -static void -log_texture_info( - SDL_Texture * const tex -) { - Uint32 format; - int access, w, h; - - // query texture - if (SDL_QueryTexture(tex, &format, &access, &w, &h)) { - die("SDL_QueryTexture(): %s", SDL_GetError()); - } - - // log information - SDL_Log( - "texture:\n" - " format = %u\n" - " access = %d\n" - " width = %d\n" - " height = %d", - format, access, w, h - ); -} -#endif /* 0 */ - static void solve_on_error( const char * const err @@ -137,18 +82,18 @@ int main(int argc, char *argv[]) { die("SDL_Init(): %s", SDL_GetError()); } - // register exit handler + // register SDL exit handler if (atexit(SDL_Quit)) { die("atexit(SDL_Init): %s", strerror(errno)); exit(EXIT_FAILURE); } - // init SDL_TTF + // init TTF if (TTF_Init()) { die("TTF_Init(): %s", TTF_GetError()); } - // register exit handler + // register TTF exit handler if (atexit(TTF_Quit)) { die("atexit(TTF_Quit): %s", strerror(errno)); exit(EXIT_FAILURE); @@ -172,7 +117,7 @@ int main(int argc, char *argv[]) { // create renderer SDL_Renderer *renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); if (!renderer) { - die("SDl_CreateRenderer(): %s", SDL_GetError()); + die("SDL_CreateRenderer(): %s", SDL_GetError()); } // set window title @@ -272,7 +217,7 @@ int main(int argc, char *argv[]) { if (sok_solve(&ctx, solve_on_error)) { // found solution, print it - draw_moves(&ctx, old_num_moves); + log_moves(&ctx, old_num_moves); } else { warn("Couldn't solve level"); } -- cgit v1.2.3