From c8fef44a1eb6daddab3eb33a35197f7a3adf6447 Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Thu, 5 Nov 2015 20:05:52 +0000 Subject: Allow selection of one or more input images --- main.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index cd87c75..7ec4c31 100644 --- a/main.c +++ b/main.c @@ -26,6 +26,11 @@ int main(int argc, char** argv) SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); + const char** paths = &argv[1]; + const int num_paths = argc - 1; + int cur_path = -1; + int next_path = 0; + int quit = 0; int redraw = 1; while(!quit) { @@ -37,8 +42,18 @@ int main(int argc, char** argv) quit = 1; break; case SDL_KEYDOWN: - if(e.key.keysym.sym == SDLK_q) { - quit = 1; + switch (e.key.keysym.sym) { + case SDLK_q: + quit = 1; + break; + case SDLK_RIGHT: + next_path = (next_path + 1) % num_paths; + break; + case SDLK_LEFT: + next_path -= 1; + if(next_path < 0) + next_path = num_paths - 1; + break; } break; case SDL_WINDOWEVENT: @@ -54,6 +69,12 @@ int main(int argc, char** argv) break; } + if(next_path != cur_path) { + cur_path = next_path; + fprintf(stdout, "current image: %s\n", paths[cur_path]); + redraw = 1; + } + if(redraw) { SDL_RenderClear(renderer); //SDL_RenderCopy(renderer, tex, srcrect, dstrect); -- cgit v1.2.3