mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-16 14:56:10 +00:00
renderer: add cursor color to custom shader uniforms
This commit is contained in:
@@ -677,6 +677,8 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
.sample_rate = 0, // N/A, we don't have any audio
|
.sample_rate = 0, // N/A, we don't have any audio
|
||||||
.current_cursor = @splat(0),
|
.current_cursor = @splat(0),
|
||||||
.previous_cursor = @splat(0),
|
.previous_cursor = @splat(0),
|
||||||
|
.current_cursor_color = @splat(0),
|
||||||
|
.previous_cursor_color = @splat(0),
|
||||||
.cursor_change_time = 0,
|
.cursor_change_time = 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -2012,25 +2014,31 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
|||||||
pixel_y += cursor_height;
|
pixel_y += cursor_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const new_cursor: [4]f32 = .{
|
||||||
|
pixel_x,
|
||||||
|
pixel_y,
|
||||||
|
cursor_width,
|
||||||
|
cursor_height,
|
||||||
|
};
|
||||||
|
const cursor_color: [4]f32 = .{
|
||||||
|
@as(f32, @floatFromInt(cursor.color[0])) / 255.0,
|
||||||
|
@as(f32, @floatFromInt(cursor.color[1])) / 255.0,
|
||||||
|
@as(f32, @floatFromInt(cursor.color[2])) / 255.0,
|
||||||
|
@as(f32, @floatFromInt(cursor.color[3])) / 255.0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uniforms = &self.custom_shader_uniforms;
|
||||||
|
|
||||||
const cursor_changed: bool =
|
const cursor_changed: bool =
|
||||||
pixel_x != self.custom_shader_uniforms.current_cursor[0] or
|
!std.meta.eql(new_cursor, uniforms.current_cursor) or
|
||||||
pixel_y != self.custom_shader_uniforms.current_cursor[1] or
|
!std.meta.eql(cursor_color, uniforms.current_cursor_color);
|
||||||
cursor_width != self.custom_shader_uniforms.current_cursor[2] or
|
|
||||||
cursor_height != self.custom_shader_uniforms.current_cursor[3];
|
|
||||||
|
|
||||||
if (cursor_changed) {
|
if (cursor_changed) {
|
||||||
self.custom_shader_uniforms.previous_cursor =
|
uniforms.previous_cursor = uniforms.current_cursor;
|
||||||
self.custom_shader_uniforms.current_cursor;
|
uniforms.previous_cursor_color = uniforms.current_cursor_color;
|
||||||
|
uniforms.current_cursor = new_cursor;
|
||||||
self.custom_shader_uniforms.current_cursor = .{
|
uniforms.current_cursor_color = cursor_color;
|
||||||
pixel_x,
|
uniforms.cursor_change_time = uniforms.time;
|
||||||
pixel_y,
|
|
||||||
cursor_width,
|
|
||||||
cursor_height,
|
|
||||||
};
|
|
||||||
|
|
||||||
self.custom_shader_uniforms.cursor_change_time =
|
|
||||||
self.custom_shader_uniforms.time;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,8 @@ layout(binding = 1, std140) uniform Globals {
|
|||||||
uniform float iSampleRate;
|
uniform float iSampleRate;
|
||||||
uniform vec4 iCurrentCursor;
|
uniform vec4 iCurrentCursor;
|
||||||
uniform vec4 iPreviousCursor;
|
uniform vec4 iPreviousCursor;
|
||||||
|
uniform vec4 iCurrentCursorColor;
|
||||||
|
uniform vec4 iPreviousCursorColor;
|
||||||
uniform float iTimeCursorChange;
|
uniform float iTimeCursorChange;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -23,6 +23,8 @@ pub const Uniforms = extern struct {
|
|||||||
sample_rate: f32 align(4),
|
sample_rate: f32 align(4),
|
||||||
current_cursor: [4]f32 align(16),
|
current_cursor: [4]f32 align(16),
|
||||||
previous_cursor: [4]f32 align(16),
|
previous_cursor: [4]f32 align(16),
|
||||||
|
current_cursor_color: [4]f32 align(16),
|
||||||
|
previous_cursor_color: [4]f32 align(16),
|
||||||
cursor_change_time: f32 align(4),
|
cursor_change_time: f32 align(4),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user