mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
pkg/glslang: complete the API
This commit is contained in:
@ -23,7 +23,7 @@ pub fn build(b: *std.Build) !void {
|
||||
test_step.dependOn(&tests_run.step);
|
||||
|
||||
// Uncomment this if we're debugging tests
|
||||
b.installArtifact(test_exe);
|
||||
// b.installArtifact(test_exe);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
pub const c = @import("c.zig");
|
||||
pub usingnamespace @import("init.zig");
|
||||
pub usingnamespace @import("program.zig");
|
||||
pub usingnamespace @import("shader.zig");
|
||||
|
||||
test {
|
||||
|
60
pkg/glslang/program.zig
Normal file
60
pkg/glslang/program.zig
Normal file
@ -0,0 +1,60 @@
|
||||
const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
const testlib = @import("test.zig");
|
||||
const Shader = @import("shader.zig").Shader;
|
||||
|
||||
pub const Program = opaque {
|
||||
pub fn create() !*Program {
|
||||
if (c.glslang_program_create()) |ptr| return @ptrCast(ptr);
|
||||
return error.OutOfMemory;
|
||||
}
|
||||
|
||||
pub fn delete(self: *Program) void {
|
||||
c.glslang_program_delete(@ptrCast(self));
|
||||
}
|
||||
|
||||
pub fn addShader(self: *Program, shader: *Shader) void {
|
||||
c.glslang_program_add_shader(@ptrCast(self), @ptrCast(shader));
|
||||
}
|
||||
|
||||
pub fn link(self: *Program, messages: c_int) !void {
|
||||
if (c.glslang_program_link(@ptrCast(self), messages) != 0) return;
|
||||
return error.GlslangFailed;
|
||||
}
|
||||
|
||||
pub fn spirvGenerate(self: *Program, stage: c.glslang_stage_t) void {
|
||||
c.glslang_program_spirv_generate(@ptrCast(self), stage);
|
||||
}
|
||||
|
||||
pub fn spirvGetSize(self: *Program) usize {
|
||||
return @intCast(c.glslang_program_spirv_get_size(@ptrCast(self)));
|
||||
}
|
||||
|
||||
pub fn spirvGet(self: *Program, buf: []u8) void {
|
||||
c.glslang_program_spirv_get(@ptrCast(self), buf.ptr);
|
||||
}
|
||||
|
||||
pub fn spirvGetPtr(self: *Program) ![*]u8 {
|
||||
return c.glslang_program_SPIRV_get_ptr(@ptrCast(self));
|
||||
}
|
||||
|
||||
pub fn sprivGetMessages(self: *Program) ![:0]const u8 {
|
||||
const ptr = c.glslang_program_spirv_get_messages(@ptrCast(self));
|
||||
return std.mem.sliceTo(ptr, 0);
|
||||
}
|
||||
|
||||
pub fn getInfoLog(self: *Program) ![:0]const u8 {
|
||||
const ptr = c.glslang_program_get_info_log(@ptrCast(self));
|
||||
return std.mem.sliceTo(ptr, 0);
|
||||
}
|
||||
|
||||
pub fn getDebugInfoLog(self: *Program) ![:0]const u8 {
|
||||
const ptr = c.glslang_program_get_info_debug_log(@ptrCast(self));
|
||||
return std.mem.sliceTo(ptr, 0);
|
||||
}
|
||||
};
|
||||
|
||||
test {
|
||||
var program = try Program.create();
|
||||
defer program.delete();
|
||||
}
|
Reference in New Issue
Block a user