aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2015-11-05 20:05:52 +0000
committerHarry Jeffery <harry@exec64.co.uk>2015-11-05 20:05:52 +0000
commitc8fef44a1eb6daddab3eb33a35197f7a3adf6447 (patch)
treee197ea6d43a73fec5158c10ba1ef5e99f87052ed
parent702984185cbd8fb807e5d540f668072d4843e293 (diff)
downloadimv-c8fef44a1eb6daddab3eb33a35197f7a3adf6447.tar.gz
Allow selection of one or more input images
-rw-r--r--main.c25
1 files 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);