mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 07:46:12 +03:00
opengl: unbind programs
This commit is contained in:
@ -92,7 +92,8 @@ pub fn setScreenSize(self: *TextRenderer, w: i32, h: i32) !void {
|
||||
@intToFloat(f32, h),
|
||||
);
|
||||
|
||||
try self.program.use();
|
||||
const bind = try self.program.use();
|
||||
defer bind.unbind();
|
||||
try self.program.setUniform("projection", self.projection);
|
||||
}
|
||||
|
||||
@ -153,7 +154,8 @@ pub fn render(
|
||||
}
|
||||
}
|
||||
|
||||
try self.program.use();
|
||||
const pbind = try self.program.use();
|
||||
defer pbind.unbind();
|
||||
|
||||
// Bind our texture and set our data
|
||||
try gl.Texture.active(gl.c.GL_TEXTURE0);
|
||||
|
@ -11,6 +11,12 @@ const errors = @import("errors.zig");
|
||||
|
||||
id: c.GLuint,
|
||||
|
||||
const Binding = struct {
|
||||
pub inline fn unbind(_: Binding) void {
|
||||
c.glUseProgram(0);
|
||||
}
|
||||
};
|
||||
|
||||
pub inline fn create() !Program {
|
||||
const id = c.glCreateProgram();
|
||||
if (id == 0) try errors.mustError();
|
||||
@ -61,8 +67,9 @@ pub inline fn link(p: Program) !void {
|
||||
return error.CompileFailed;
|
||||
}
|
||||
|
||||
pub inline fn use(p: Program) !void {
|
||||
pub inline fn use(p: Program) !Binding {
|
||||
c.glUseProgram(p.id);
|
||||
return Binding{};
|
||||
}
|
||||
|
||||
/// Requires the program is currently in use.
|
||||
|
Reference in New Issue
Block a user