From 2d71f1099f0eb3ef6e17316a520d3d710dec1ac0 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Tue, 11 Feb 2025 11:06:28 +0100 Subject: Memory buffer fixes --- examples/screenshot.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'examples') diff --git a/examples/screenshot.c b/examples/screenshot.c index c3c0ebd..11b2385 100644 --- a/examples/screenshot.c +++ b/examples/screenshot.c @@ -1,23 +1,34 @@ #include "../graphics.c" -i64 width = 0; -i64 height = 0; -b8 has_screenshot = 0; +enum { + MAX_NUM_PIXELS = 10 * 1024 * 1024, +}; + +b8 has_screenshot = 0; +i64 width = 0; +i64 height = 0; +vec4_f32 pixels[MAX_NUM_PIXELS] = {0}; void update_and_render_frame(void) { if (!has_screenshot) { - take_screenshot(MAX_NUM_PIXELS, &width, &height, g_platform.sketch); + take_screenshot(MAX_NUM_PIXELS, &width, &height, pixels); has_screenshot = 1; } handle_main_window_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, - }); + draw_pixels_quick( + (Box) { + .width = g_platform.real_width, + .height = g_platform.real_height, + }, + (Pixel_Buffer) { + .width = width, + .height = height, + .stride = width, + .pixels = pixels, + } + ); render_main_window_frame(); } -- cgit v1.2.3