blob: e717a95b679f05948e207a5f031c7a94752fc905 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#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.startFrame = 0;
fc.endFrame = totalFrames;
fc.frame = f;
for (usize i = 0; i < sizeCallbacks; ++i) {
// Soft context reset
if (callbacks[i] == NULL) {
fc.startFrame = 0;
fc.endFrame = totalFrames;
fc.frame = f;
}
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);
}
|