summaryrefslogtreecommitdiff
path: root/AnimationRender/AnimationRender.c
diff options
context:
space:
mode:
Diffstat (limited to 'AnimationRender/AnimationRender.c')
-rw-r--r--AnimationRender/AnimationRender.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/AnimationRender/AnimationRender.c b/AnimationRender/AnimationRender.c
new file mode 100644
index 0000000..8974ba3
--- /dev/null
+++ b/AnimationRender/AnimationRender.c
@@ -0,0 +1,26 @@
+#include "AnimationRender.h"
+#include "FrameCallback.h"
+
+void RenderAnimation(u32 width, u32 height, u32 totalFrames, const FrameCallback** callbacks, usize sizeCallbacks) {
+ RGBImage frameBuffer = RGBImage_new(width, height);
+
+ struct FrameContext fc;
+ fc.startFrame = 0;
+ fc.endFrame = totalFrames;
+ fc.frameBuffer = frameBuffer;
+
+ for (u32 f = 0; f < totalFrames; ++f) {
+ fc.frame = f;
+ for (usize i = 0; i < sizeCallbacks; ++i) {
+ // Soft context reset
+ if (callbacks[i] == NULL) {
+ fc.startFrame = 0;
+ fc.endFrame = totalFrames;
+ }
+ else
+ callbacks[i]->callback(callbacks[i]->callback_self, &fc);
+ }
+ }
+
+ RGBImage_delete(&frameBuffer);
+}