renderer/opengl: set resolution uniform on screen size change

This commit is contained in:
Mitchell Hashimoto
2023-11-17 16:58:36 -08:00
parent 2559d6b367
commit fbc13d08b0
2 changed files with 28 additions and 2 deletions

View File

@@ -107,8 +107,11 @@ draw_background: terminal.color.RGB,
const SetScreenSize = struct {
size: renderer.ScreenSize,
fn apply(self: SetScreenSize, r: *const OpenGL) !void {
const gl_state = r.gl_state orelse return error.OpenGLUninitialized;
fn apply(self: SetScreenSize, r: *OpenGL) !void {
const gl_state: *GLState = if (r.gl_state) |*v|
v
else
return error.OpenGLUninitialized;
// Apply our padding
const padding = if (r.padding.balance)
@@ -146,6 +149,11 @@ const SetScreenSize = struct {
-1 * @as(f32, @floatFromInt(padding.top)),
),
);
// Update our custom shader resolution
if (gl_state.custom) |*custom_state| {
try custom_state.setScreenSize(self.size);
}
}
};