summaryrefslogtreecommitdiff
path: root/AnimationRender
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2026-03-28 22:26:34 +0200
committerSyndamia <kamen@syndamia.com>2026-03-28 22:26:52 +0200
commitaf9f6ae727a15b965789717047a52e6857a3bd8d (patch)
tree8b7b3daeff4a759a6c5403bd7a17a63d67e55a7d /AnimationRender
parent1cc8f72fb1c44e203a324e274038c2883c351fbb (diff)
downloadppm_graphics-af9f6ae727a15b965789717047a52e6857a3bd8d.tar
ppm_graphics-af9f6ae727a15b965789717047a52e6857a3bd8d.tar.gz
ppm_graphics-af9f6ae727a15b965789717047a52e6857a3bd8d.zip
feat: Better timing handling
Diffstat (limited to 'AnimationRender')
-rw-r--r--AnimationRender/AnimationRender.c4
-rw-r--r--AnimationRender/F_Draw.c5
-rw-r--r--AnimationRender/F_Draw.h2
-rw-r--r--AnimationRender/F_FrameRange.c18
-rw-r--r--AnimationRender/F_FrameRange.h15
5 files changed, 37 insertions, 7 deletions
diff --git a/AnimationRender/AnimationRender.c b/AnimationRender/AnimationRender.c
index 8974ba3..68bb7b7 100644
--- a/AnimationRender/AnimationRender.c
+++ b/AnimationRender/AnimationRender.c
@@ -16,10 +16,12 @@ void RenderAnimation(u32 width, u32 height, u32 totalFrames, const FrameCallback
if (callbacks[i] == NULL) {
fc.startFrame = 0;
fc.endFrame = totalFrames;
+ fc.frame = f;
}
- else
+ else if (fc.startFrame <= fc.frame && fc.frame <= fc.endFrame)
callbacks[i]->callback(callbacks[i]->callback_self, &fc);
}
+ ppm6_write(stdout, frameBuffer);
}
RGBImage_delete(&frameBuffer);
diff --git a/AnimationRender/F_Draw.c b/AnimationRender/F_Draw.c
index fb90883..90b5986 100644
--- a/AnimationRender/F_Draw.c
+++ b/AnimationRender/F_Draw.c
@@ -4,10 +4,7 @@
#include <string.h>
void Draw_callback(Draw* self, struct FrameContext* fc) {
- if (self->startFrame <= fc->frame && fc->frame <= self->endFrame) {
- RenderFrame(fc->frameBuffer, self->callbacks, self->sizeCallbacks);
- ppm6_write(stdout, fc->frameBuffer);
- }
+ RenderFrame(fc->frameBuffer, self->callbacks, self->sizeCallbacks);
}
FrameCallback* Draw_setup(Draw obj) {
diff --git a/AnimationRender/F_Draw.h b/AnimationRender/F_Draw.h
index 729cec9..5150347 100644
--- a/AnimationRender/F_Draw.h
+++ b/AnimationRender/F_Draw.h
@@ -6,8 +6,6 @@
#include "FrameCallback.h"
typedef struct Draw {
- u32 startFrame;
- u32 endFrame;
const PixelCallback** callbacks;
usize sizeCallbacks;
} Draw;
diff --git a/AnimationRender/F_FrameRange.c b/AnimationRender/F_FrameRange.c
new file mode 100644
index 0000000..0a1da6d
--- /dev/null
+++ b/AnimationRender/F_FrameRange.c
@@ -0,0 +1,18 @@
+#include "F_FrameRange.h"
+#include <stdlib.h>
+#include <string.h>
+
+void FrameRange_callback(FrameRange* self, struct FrameContext* fc) {
+ fc->startFrame = self->startFrame;
+ fc->endFrame = self->endFrame;
+}
+
+FrameCallback* FrameRange_setup(FrameRange obj) {
+ FrameCallback* fca = malloc(sizeof(struct FrameCallback));
+
+ fca->callback = (FrameCallback_callback)FrameRange_callback;
+ fca->callback_self = malloc(sizeof(obj));
+ memcpy(fca->callback_self, &obj, sizeof(obj));
+
+ return fca;
+}
diff --git a/AnimationRender/F_FrameRange.h b/AnimationRender/F_FrameRange.h
new file mode 100644
index 0000000..2eaa474
--- /dev/null
+++ b/AnimationRender/F_FrameRange.h
@@ -0,0 +1,15 @@
+#ifndef F_FRAME_RANGE
+#define F_FRAME_RANGE
+
+#include "../global.h"
+#include "../FrameRender/PixelCallback.h"
+#include "FrameCallback.h"
+
+typedef struct FrameRange {
+ u32 startFrame;
+ u32 endFrame;
+} FrameRange;
+
+FrameCallback* FrameRange_setup(FrameRange obj);
+
+#endif /* F_FRAME_RANGE */