feat(renderer): port the OpenGL backend, shaders and size math
Ports the terminal-independent half of ZIG/src/renderer (OpenGL only): - opengl/*: buffers, frames, pipelines, render passes, samplers, targets, textures and the OpenGL GraphicsAPI backend on top of glow; the GTK GLArea glue is replaced by a get_proc_address loader closure - the GLSL shaders, copied verbatim and embedded; uniform/vertex structs as bytemuck Pod types with std140 offsets asserted in tests - shadertoy custom shaders converted with naga (GLSL in -> validate -> GLSL 430 out) instead of glslang + spirv-cross - size (screen/grid/cell/padding math), cursor style logic, backend health, options and message types The crate opts into unsafe_code = "deny"; unsafe glow calls live only in opengl/gl.rs. A headless EGL integration test builds every pipeline and the converted shadertoy shaders on Mesa and reads back rendered pixels. Note: Zig's shadertoy Uniforms order the selection background/foreground colors opposite to the GLSL block (likely an upstream bug); kept as in Zig for parity and recorded in the notes. Deferred to the next renderer pass: generic, cell, image, link, row, State, Thread, Overlay (need terminal render state). Test Plan: - cargo test -p ghostty-renderer (33 tests incl. tests/egl_headless.rs)
This commit is contained in:
1 parent
5a5fa7893b
commit
568ce784f9
35 files changed
+5477
-5
No files matched your search
@@ -0,0 +1,41 @@
|
||||
// Test shader for iTimeFocus and iFocus
|
||||
// Shows border when focused, green fade that restarts on each focus gain
|
||||
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
||||
vec2 uv = fragCoord / iResolution.xy;
|
||||
|
||||
// Sample the terminal content
|
||||
vec4 terminal = texture2D(iChannel0, uv);
|
||||
vec3 color = terminal.rgb;
|
||||
|
||||
if (iFocus > 0) {
|
||||
// FOCUSED: Add border and fading green overlay
|
||||
|
||||
// Calculate time since focus was gained
|
||||
float timeSinceFocus = iTime - iTimeFocus;
|
||||
|
||||
// Green fade: starts at 1.0 (full green), fades to 0.0 over 3 seconds
|
||||
float fadeOut = max(0.0, 1.0 - (timeSinceFocus / 3.0));
|
||||
|
||||
// Add green overlay that fades out
|
||||
color = mix(color, vec3(0.0, 1.0, 0.0), fadeOut * 0.4);
|
||||
|
||||
// Add border (5 pixels)
|
||||
float borderSize = 5.0;
|
||||
vec2 pixelCoord = fragCoord;
|
||||
bool isBorder = pixelCoord.x < borderSize ||
|
||||
pixelCoord.x > iResolution.x - borderSize ||
|
||||
pixelCoord.y < borderSize ||
|
||||
pixelCoord.y > iResolution.y - borderSize;
|
||||
|
||||
if (isBorder) {
|
||||
// Bright cyan border that pulses subtly
|
||||
float pulse = sin(timeSinceFocus * 2.0) * 0.1 + 0.9;
|
||||
color = vec3(0.0, 1.0, 1.0) * pulse;
|
||||
}
|
||||
} else {
|
||||
// UNFOCUSED: Solid red overlay (no border)
|
||||
color = mix(color, vec3(1.0, 0.0, 0.0), 0.3);
|
||||
}
|
||||
|
||||
fragColor = vec4(color, 1.0);
|
||||
}
|
||||
Reference in new issue
Block a user