Skip to content

Wrapper: createProgram and createShader can return error. #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/wrapper.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2571,13 +2571,21 @@ pub fn Wrap(comptime bindings: anytype) type {
}

// pub var createProgram: *const fn () callconv(.C) Uint = undefined;
pub fn createProgram() Program {
return @enumFromInt(bindings.createProgram());
pub fn createProgram() !Program {
const maybe_program = bindings.createProgram();
if (maybe_program <= @intFromEnum(Program.invalid)) {
return error.glCreateProgramFailed;
}
return @enumFromInt(maybe_program);
}

// pub var createShader: *const fn (type: Enum) callconv(.C) Uint = undefined;
pub fn createShader(@"type": ShaderType) Shader {
return @enumFromInt(bindings.createShader(@intFromEnum(@"type")));
pub fn createShader(@"type": ShaderType) !Shader {
const maybe_shader = bindings.createShader(@intFromEnum(@"type"));
if (maybe_shader <= @intFromEnum(Shader.invalid)) {
return error.glCreateShaderFailed;
}
return @enumFromInt(maybe_shader);
}

// pub var deleteProgram: *const fn (program: Uint) callconv(.C) void = undefined;
Expand Down
Loading