mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-12 12:56:06 +00:00
renderer/opengl: start custom program work
This commit is contained in:
36
src/renderer/opengl/CustomProgram.zig
Normal file
36
src/renderer/opengl/CustomProgram.zig
Normal file
@@ -0,0 +1,36 @@
|
||||
/// The OpenGL program for custom shaders.
|
||||
const CustomProgram = @This();
|
||||
|
||||
const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
const gl = @import("opengl");
|
||||
|
||||
program: gl.Program,
|
||||
|
||||
pub fn createList(alloc: Allocator, srcs: []const [:0]const u8) ![]const CustomProgram {
|
||||
var programs = std.ArrayList(CustomProgram).init(alloc);
|
||||
defer programs.deinit();
|
||||
errdefer for (programs.items) |program| program.deinit();
|
||||
|
||||
for (srcs) |src| {
|
||||
try programs.append(try CustomProgram.init(src));
|
||||
}
|
||||
|
||||
return try programs.toOwnedSlice();
|
||||
}
|
||||
|
||||
pub fn init(src: [:0]const u8) !CustomProgram {
|
||||
const program = try gl.Program.createVF(
|
||||
@embedFile("../shaders/custom.v.glsl"),
|
||||
src,
|
||||
);
|
||||
errdefer program.destroy();
|
||||
|
||||
return .{
|
||||
.program = program,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn deinit(self: CustomProgram) void {
|
||||
self.program.destroy();
|
||||
}
|
Reference in New Issue
Block a user