From 0d203543cad85c06f6911758ead0580580a84657 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sat, 8 Jan 2022 18:52:11 -0400 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); }