aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2015-11-11 09:58:23 +0000
committerHarry Jeffery <harry@exec64.co.uk>2015-11-11 09:58:23 +0000
commit497e3d5b470d091b7e109a7116313041cddc6c14 (patch)
treeda0c93d290b2b889d3056e9f2aca2571322c8f9b
parent09c807871055a857fd1be936fa3219d4838c1151 (diff)
downloadimv-497e3d5b470d091b7e109a7116313041cddc6c14.tar.gz
Let imv_image track changes to itself
-rw-r--r--image.c13
-rw-r--r--image.h3
-rw-r--r--main.c4
3 files changed, 17 insertions, 3 deletions
diff --git a/image.c b/image.c
index 1b50ce8..1fb8094 100644
--- a/image.c
+++ b/image.c
@@ -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;
+ }
+}
diff --git a/image.h b/image.h
index 4ae3c10..d36dab4 100644
--- a/image.h
+++ b/image.h
@@ -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
diff --git a/main.c b/main.c
index 6ae90bc..6a49fe0 100644
--- a/main.c
+++ b/main.c
@@ -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);
}