#zig-opengl error

1 messages · Page 1 of 1 (latest)

leaden quiver
#
const glfw = @import("zglfw");
const zopengl = @import("zopengl");
const std = @import("std");

pub fn main() !void {
    try glfw.init();
    defer glfw.terminate();

    const window = try glfw.createWindow(600, 600, "main", null);
    defer glfw.destroyWindow(window);

    glfw.makeContextCurrent(window);

    try zopengl.loadCoreProfile(getProcAddress, 4, 0);
    const gl = zopengl.bindings;

    while (!window.shouldClose()) {
        glfw.pollEvents();

        gl.clearColor(0.1, 0.1, 0.1, 1);
        gl.clear(gl.COLOR_BUFFER_BIT);

        window.swapBuffers();
    }
}

fn getProcAddress(name: [*:0]const u8) callconv(.c) ?*const anyopaque {
    return glfw.getProcAddress(name);
}

is giving this error

Segmentation fault at address 0x0
???:?:?: 0x0 in ??? (???)
zsh: IOT instruction (core dumped)  ./zig-out/bin/opengl
peak breach
#

you need to tell glfw which opengl version to use```ts
glfw.windowHint(.context_version_major, 4);
glfw.windowHint(.context_version_minor, 0);
glfw.windowHint(.opengl_profile, .opengl_core_profile);
glfw.windowHint(.opengl_forward_compat, true);

leaden quiver
#

Tried but same error

peak breach
#

can you post your build.zig?