diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2015-11-11 09:58:23 +0000 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2015-11-11 09:58:23 +0000 |
commit | 497e3d5b470d091b7e109a7116313041cddc6c14 (patch) | |
tree | da0c93d290b2b889d3056e9f2aca2571322c8f9b | |
parent | 09c807871055a857fd1be936fa3219d4838c1151 (diff) | |
download | imv-497e3d5b470d091b7e109a7116313041cddc6c14.tar.gz |
Let imv_image track changes to itself
-rw-r--r-- | image.c | 13 | ||||
-rw-r--r-- | image.h | 3 | ||||
-rw-r--r-- | main.c | 4 |
3 files changed, 17 insertions, 3 deletions
@@ -29,6 +29,7 @@ void imv_init_image(struct imv_image *img) img->next_frame = 0; img->num_frames = 0; img->frame_time = 0; + img->changed = 0; } void imv_destroy_image(struct imv_image *img) @@ -106,6 +107,7 @@ int imv_image_load(struct imv_image *img, const char* path) img->height = FreeImage_GetHeight(img->cur_bmp); } + img->changed = 1; return 0; } @@ -196,6 +198,7 @@ void imv_image_load_next_frame(struct imv_image *img) case 3: /* TODO - restore to previous content */ break; } + img->changed = 1; } int imv_image_is_animated(struct imv_image *img) @@ -215,3 +218,13 @@ void imv_image_play(struct imv_image *img, double time) imv_image_load_next_frame(img); } } + +int imv_image_has_changed(struct imv_image *img) +{ + if(img->changed) { + img->changed = 0; + return 1; + } else { + return 0; + } +} @@ -30,6 +30,7 @@ struct imv_image { int cur_frame; int next_frame; int num_frames; + int changed; double frame_time; }; @@ -43,4 +44,6 @@ void imv_image_load_next_frame(struct imv_image *img); int imv_image_is_animated(struct imv_image *img); void imv_image_play(struct imv_image *img, double time); +int imv_image_has_changed(struct imv_image *img); + #endif @@ -226,9 +226,7 @@ int main(int argc, char** argv) break; } - int resend = 0; while(imv_navigator_get_current_path(&nav) != current_path) { - resend = 1; current_path = imv_navigator_get_current_path(&nav); if(!current_path) { @@ -253,7 +251,7 @@ int main(int argc, char** argv) } } - if(resend) { + if(imv_image_has_changed(&img)) { imv_texture_set_image(&tex, img.cur_bmp); imv_viewport_set_redraw(&view); } |