main_raw.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include <assert.h>
  2. #include <stdio.h>
  3. #include <stdint.h>
  4. #include <string.h>
  5. #include <errno.h>
  6. #define OLIVEC_IMPLEMENTATION
  7. #include "olive.c"
  8. #include "ffmpeg.h"
  9. #define WIDTH 800
  10. #define HEIGHT 600
  11. #define FPS 30
  12. #define DURATION 10
  13. uint32_t pixels[WIDTH*HEIGHT];
  14. int main(void)
  15. {
  16. FFMPEG *ffmpeg = ffmpeg_start_rendering(WIDTH, HEIGHT, FPS);
  17. Olivec_Canvas oc = olivec_canvas(pixels, WIDTH, HEIGHT, WIDTH);
  18. float x = WIDTH/2;
  19. float y = HEIGHT/2;
  20. float r = HEIGHT/8;
  21. float dx = 200;
  22. float dy = 200;
  23. float dt = 1.0f/FPS;
  24. for (size_t i = 0; i < FPS*DURATION; ++i) {
  25. float nx = x + dx*dt;
  26. if (0 < nx - r && nx + r < WIDTH) {
  27. x = nx;
  28. } else {
  29. dx = -dx;
  30. }
  31. float ny = y + dy*dt;
  32. if (0 < ny - r && ny + r < HEIGHT) {
  33. y = ny;
  34. } else {
  35. dy = -dy;
  36. }
  37. olivec_fill(oc, 0xFF181818);
  38. olivec_circle(oc, x, y, r, 0xFF0000FF);
  39. ffmpeg_send_frame(ffmpeg, pixels, WIDTH, HEIGHT);
  40. }
  41. ffmpeg_end_rendering(ffmpeg);
  42. printf("Done rendering the video!\n");
  43. return 0;
  44. }