mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-12 12:56:06 +00:00
renderer/opengl: create ubos
This commit is contained in:
@@ -7,6 +7,19 @@ const gl = @import("opengl");
|
||||
|
||||
program: gl.Program,
|
||||
|
||||
pub const Uniforms = extern struct {
|
||||
resolution: [3]f32 align(16),
|
||||
time: f32 align(4),
|
||||
time_delta: f32 align(4),
|
||||
frame_rate: f32 align(4),
|
||||
frame: i32 align(4),
|
||||
channel_time: [4][4]f32 align(16),
|
||||
channel_resolution: [4][4]f32 align(16),
|
||||
mouse: [4]f32 align(16),
|
||||
date: [4]f32 align(16),
|
||||
sample_rate: f32 align(4),
|
||||
};
|
||||
|
||||
pub fn createList(alloc: Allocator, srcs: []const [:0]const u8) ![]const CustomProgram {
|
||||
var programs = std.ArrayList(CustomProgram).init(alloc);
|
||||
defer programs.deinit();
|
||||
@@ -26,6 +39,13 @@ pub fn init(src: [:0]const u8) !CustomProgram {
|
||||
);
|
||||
errdefer program.destroy();
|
||||
|
||||
// Create our uniform buffer that is shared across all custom shaders
|
||||
const ubo = try gl.Buffer.create();
|
||||
errdefer ubo.destroy();
|
||||
var ubobind = try ubo.bind(.uniform);
|
||||
defer ubobind.unbind();
|
||||
try ubobind.setDataNull(Uniforms, .static_draw);
|
||||
|
||||
return .{
|
||||
.program = program,
|
||||
};
|
||||
|
Reference in New Issue
Block a user