diff options
Diffstat (limited to 'src/sdl')
-rw-r--r-- | src/sdl/log-renderer-info.c | 34 | ||||
-rw-r--r-- | src/sdl/log-renderer-info.h | 8 | ||||
-rw-r--r-- | src/sdl/main.c | 69 |
3 files changed, 49 insertions, 62 deletions
diff --git a/src/sdl/log-renderer-info.c b/src/sdl/log-renderer-info.c new file mode 100644 index 0000000..3e05307 --- /dev/null +++ b/src/sdl/log-renderer-info.c @@ -0,0 +1,34 @@ +#include "util.h" +#include "log-renderer-info.h" + +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 = 0x%04X%s%s%s%s\n" + " max_texture_width = %d\n" + " max_texture_height = %d\n" + " num_texture_formats = %u", + 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.max_texture_width, + info.max_texture_height, + info.num_texture_formats + ); +} + diff --git a/src/sdl/log-renderer-info.h b/src/sdl/log-renderer-info.h new file mode 100644 index 0000000..a7ab115 --- /dev/null +++ b/src/sdl/log-renderer-info.h @@ -0,0 +1,8 @@ +#ifndef LOG_RENDERER_INFO +#define LOG_RENDERER_INFO + +#include <SDL.h> + +void log_renderer_info(SDL_Renderer * const); + +#endif /* LOG_RENDERER_INFO */ 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 ) { @@ -32,62 +33,6 @@ draw_moves( } 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"); } |