From f9aefedf60ba958a7bb6764e7631729a8ce1e68a Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Tue, 29 Nov 2022 23:35:13 -0400 Subject: [PATCH] chore: cal glDeleteTextures on program exit --- src/platform.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platform.zig b/src/platform.zig index dc52ef3..426bd2c 100644 --- a/src/platform.zig +++ b/src/platform.zig @@ -64,7 +64,7 @@ pub const Gui = struct { const ctx = SDL.SDL_GL_CreateContext(window) orelse panic(); if (SDL.SDL_GL_MakeCurrent(window, ctx) < 0) panic(); - gl.load(ctx, Self.glGetProcAddress) catch @panic("gl.load failed"); + try gl.load(ctx, Self.glGetProcAddress); if (SDL.SDL_GL_SetSwapInterval(@boolToInt(config.config().host.vsync)) < 0) panic(); const program_id = try compileShaders(); @@ -164,9 +164,10 @@ pub const Gui = struct { gl.deleteBuffers(1, &buffer_ids[1]); // VBO gl.deleteVertexArrays(1, &buffer_ids[0]); // VAO } - const vao_id = buffer_ids[0]; - _ = Self.generateTexture(cpu.bus.ppu.framebuf.get(.Renderer)); + + const tex_id = Self.generateTexture(cpu.bus.ppu.framebuf.get(.Renderer)); + defer gl.deleteTextures(1, &tex_id); const thread = try std.Thread.spawn(.{}, emu.run, .{ &quit, scheduler, cpu, &tracker }); defer thread.join(); @@ -250,7 +251,6 @@ pub const Gui = struct { pub fn deinit(self: *Self) void { self.audio.deinit(); - // TODO: Buffer deletions gl.deleteProgram(self.program_id); SDL.SDL_GL_DeleteContext(self.ctx); SDL.SDL_DestroyWindow(self.window);