From f28b963f9ddcab9f3343cb6905241c20794f238b Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:11:51 -0300 Subject: [PATCH] chore: add code for heap alloc of white texture --- src/main.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index 837d516..79667ae 100644 --- a/src/main.zig +++ b/src/main.zig @@ -61,6 +61,10 @@ pub fn main() anyerror!void { const buf_len = buf_pitch * 160; var white: [buf_len]u8 = [_]u8{ 0xFF, 0x7F } ** (buf_len / 2); + var white_heap = try alloc.alloc(u8, buf_len); + for (white) |b, i| white_heap[i] = b; + defer alloc.free(white_heap); + emu_loop: while (true) { emu.runFrame(&scheduler, &cpu, &bus); @@ -72,7 +76,7 @@ pub fn main() anyerror!void { else => {}, } - _ = SDL.SDL_UpdateTexture(texture, null, &white, buf_pitch); + _ = SDL.SDL_UpdateTexture(texture, null, &white_heap, buf_pitch); _ = SDL.SDL_RenderCopy(renderer, texture, null, null); SDL.SDL_RenderPresent(renderer); }