diff options
| author | s-ol <s+removethis@s-ol.nu> | 2025-07-27 21:39:42 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-07-27 21:44:11 +0000 |
| commit | 0e57849232ce28c6b39df7777f48641fa97fbb58 (patch) | |
| tree | 0af7c30a181bfb98788544d49f4ba952aca38a77 | |
| parent | update gitignore (diff) | |
| download | glsl-view-0e57849232ce28c6b39df7777f48641fa97fbb58.tar.gz glsl-view-0e57849232ce28c6b39df7777f48641fa97fbb58.zip | |
fix texture binding bug
| -rw-r--r-- | src/ffmpeg.zig | 5 | ||||
| -rw-r--r-- | src/gl.zig | 5 | ||||
| -rw-r--r-- | src/hap.zig | 2 | ||||
| -rw-r--r-- | src/main.zig | 4 |
4 files changed, 11 insertions, 5 deletions
diff --git a/src/ffmpeg.zig b/src/ffmpeg.zig index 9d3bc9a..f848ef8 100644 --- a/src/ffmpeg.zig +++ b/src/ffmpeg.zig @@ -53,6 +53,9 @@ pub const Decoder = struct { const more = try self.process_packet_fn(self, packet, texture); progress.setCompletedItems(@intCast(self.num_frames)); if (!more) break; + if (texture) |tex| { + if (tex.type == .TEXTURE_2D) break; + } } c.av_packet_unref(packet); } else { @@ -204,7 +207,7 @@ pub const AVDecoder = struct { self.rgba_frame.*.data[0], ); - if (tex.type == .TEXTURE_2D) return false; + if (tex.type == .TEXTURE_2D) return true; } self.decoder.num_frames += 1; @@ -50,7 +50,7 @@ pub const Texture = struct { pub fn bind(self: *Texture) usize { if (self.image_unit == null) { - for (image_unit_map[0..], 0..) |*slot, i| { + for (image_unit_map[0..], 1..) |*slot, i| { if (slot.*) continue; slot.* = true; @@ -61,6 +61,7 @@ pub const Texture = struct { if (self.image_unit) |image_unit| { c.glActiveTexture(@intCast(c.GL_TEXTURE0 + image_unit)); + defer c.glActiveTexture(@intCast(c.GL_TEXTURE0)); c.glBindTexture(@intFromEnum(self.type), self.id); return image_unit; } else unreachable; @@ -887,7 +888,7 @@ pub const Source = struct { texture: Texture, update_fn: ?*const fn (self: *Source) void, - deinit_fn: *const fn (self: *const Source, allocator: std.mem.Allocator) void, + deinit_fn: *const fn (self: *Source, allocator: std.mem.Allocator) void, pub fn update(self: *Source) void { if (self.update_fn) |inner| inner(self); diff --git a/src/hap.zig b/src/hap.zig index 696b905..c2db8bb 100644 --- a/src/hap.zig +++ b/src/hap.zig @@ -110,7 +110,7 @@ pub const HAPDecoder = struct { buffer[0..length], ); - if (tex.type == .TEXTURE_2D) return false; + if (tex.type == .TEXTURE_2D) return true; } else { try check(c.HapGetFrameTextureFormat(packet.data, @intCast(packet.size), 0, &format)); if (self.format) |fmt| { diff --git a/src/main.zig b/src/main.zig index 96b87eb..0883c15 100644 --- a/src/main.zig +++ b/src/main.zig @@ -119,7 +119,6 @@ pub fn main() !void { while (c.glfwWindowShouldClose(window) == c.GL_FALSE) { c.glfwMakeContextCurrent(window); - c.glClear(c.GL_COLOR_BUFFER_BIT); const now_time = c.glfwGetTime(); prev_time = now_time; @@ -155,6 +154,9 @@ pub fn main() !void { if (outputs.items.len == 0) break; + c.glfwMakeContextCurrent(window); + c.glfwSwapBuffers(window); + c.glfwPollEvents(); } } |
