summaryrefslogtreecommitdiff
path: root/examples/screenshot.c
blob: 33bbe99f6387b072d8d857acd8cf59d628bec97a (plain)
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
#include "../graphics.c"

i64 width          = 0;
i64 height         = 0;
b8  has_screenshot = 0;

void update_and_render_frame(void) {
  if (!has_screenshot) {
    p_screenshot(MAX_NUM_PIXELS, &width, &height, g_platform.sketch);
    has_screenshot = 1;
  }

  p_handle_events();

  draw_pixels((Brush) { .quick = 1, }, 0, 0, g_platform.real_width, g_platform.real_height, (Pixel_Buffer) {
    .width  = width,
    .height = height,
    .stride = width,
    .pixels = g_platform.sketch,
  });

  p_render_frame();
}

i32 main(i32 argc, c8 **argv) {
  (void) argc;
  (void) argv;

  g_platform = (Platform) {
    .title = "Screenshot",
  };

  p_event_loop();

  return 0;
}