#zstbi error
1 messages · Page 1 of 1 (latest)
did u init the library?
Yupp it's done
const image = try zstbi.Image.loadFromFile("src/container.jpg", 3);
const w: c_int = @intCast(image.width);
const h: c_int = @intCast(image.height);
var tex: c_uint = undefined;
gl.genTextures(gl.TEXTURE_2D, &tex);
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, w, h, 0, gl.RGB, gl.UNSIGNED_BYTE, &image.data);
segfault is due to the last line ig
oh u edited the error in the original post, that's a bit confusing ^^'
&image.data is wrong, should be image.data.ptr
i'm not even sure how that compiles tbh
oh i guess texImage2D prolly takes an *anyopaque or smth
yeah *const anyopaque
anyway yea, this is prolly the issue
still segfault 😭
(lldb) bt
* thread #1, name = 'opengl', stop reason = signal SIGSEGV: address not mapped to object (fault address: 0x7ffffffff000)
* frame #0: 0x00007fffdc87a0fc libgallium-25.1.6.so`_mesa_HashFindFreeKeys + 60
frame #1: 0x00007fffdc8a0ff7 libgallium-25.1.6.so`create_textures.part.0 + 87
frame #2: 0x0000000001177352 opengl`main.main at main.zig:67:19
```\
i found the issue 🙂
and surely there's something wrong with this
zstbi.init(allocator);
defer zstbi.deinit();
cuz i get this error once the application window closes
thread 101375 panic: reached unreachable code
/usr/lib/zig/std/debug.zig:522:14: 0x109402d in assert (opengl)
if (!ok) unreachable; // assertion failure
^
/home/dotdot/.cache/zig/p/zstbi-0.11.0-dev-L0Ea_-eVBwCl8RYA98PhLDw3Fhw5k7FJOHSMDKWDOvqx/src/zstbi.zig:25:11: 0x1171ffa in deinit (opengl)
assert(mem_allocations.?.count() == 0);
^
/home/dotdot/Documents/zig/opengl/src/main.zig:42:23: 0x1171b72 in main (opengl)
defer zstbi.deinit();
^
/usr/lib/zig/std/start.zig:656:37: 0x1172767 in main (opengl)
const result = root.main() catch |err| {
^
???:?:?: 0x7f34bc24d487 in ??? (libc.so.6)
Unwind information for `libc.so.6:0x7f34bc24d487` was not available, trace may be incomplete
???:?:?: 0x7f34bc24d54a in ??? (libc.so.6)
???:?:?: 0x10635a4 in ??? (???)
zsh: IOT instruction (core dumped) ./zig-out/bin/opengl