blob: 68bb7b7ad1177b6c7479b1394ac349d1a7100638 (
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
|
#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;
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);
}
|