-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain_raw.c
56 lines (44 loc) · 1.12 KB
/
main_raw.c
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#define OLIVEC_IMPLEMENTATION
#include "olive.c"
#include "ffmpeg.h"
#define WIDTH 800
#define HEIGHT 600
#define FPS 30
#define DURATION 10
uint32_t pixels[WIDTH*HEIGHT];
int main(void)
{
FFMPEG *ffmpeg = ffmpeg_start_rendering(WIDTH, HEIGHT, FPS);
Olivec_Canvas oc = olivec_canvas(pixels, WIDTH, HEIGHT, WIDTH);
float x = WIDTH/2;
float y = HEIGHT/2;
float r = HEIGHT/8;
float dx = 200;
float dy = 200;
float dt = 1.0f/FPS;
for (size_t i = 0; i < FPS*DURATION; ++i) {
float nx = x + dx*dt;
if (0 < nx - r && nx + r < WIDTH) {
x = nx;
} else {
dx = -dx;
}
float ny = y + dy*dt;
if (0 < ny - r && ny + r < HEIGHT) {
y = ny;
} else {
dy = -dy;
}
olivec_fill(oc, 0xFF181818);
olivec_circle(oc, x, y, r, 0xFF0000FF);
ffmpeg_send_frame(ffmpeg, pixels, WIDTH, HEIGHT);
}
ffmpeg_end_rendering(ffmpeg);
printf("Done rendering the video!\n");
return 0;
}