1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
//! A test addon whose GPU picture is translucent: its pass draws nothing
//! and clears to a premultiplied half-alpha colour, so the window's addon
//! pipeline blends it over the pane (the frame corpus's case for the
//! pipeline's colour factor, which an opaque picture never shows).
const std = @import("std");
const addon = @import("addon");
const scene = @import("gpu_scene");
pub const Veil = extern struct {
painted: u32,
pub const head: addon.Head = .{ .name = "veil", .version = 1, .words = &.{
.{ .name = "Veil", .opens = true, .doc = "a translucent GPU picture over the pane (a test addon)" },
} };
pub fn open(v: *Veil, _: ?[]const u8, _: ?[]const u8) void {
v.painted = 0;
}
pub fn paint(_: *const Veil, w: addon.Window, out: addon.Paint) void {
w.put(0, 0, "veil over this", .{});
const width: u32 = @min(4096, @max(1, @as(u32, w.cols) * w.cell_w));
const height: u32 = @min(4096, @max(1, @as(u32, w.rows) * w.cell_h));
var buffer: [256]u8 = undefined;
var writer: std.Io.Writer = .fixed(&buffer);
scene.encode(&writer, .{ .image = .none, .width = width, .height = height, .clear = .{ 0.30, 0.10, 0.20, 0.5 }, .pipelines = &.{}, .draws = &.{} }) catch return;
_ = out.gpu(writer.buffered());
}
pub const dump = addon.dumpBytes;
pub const load = addon.loadBytes;
};
pub const pardes_addon = addon.ops(Veil);
comptime {
addon.exportLib(&pardes_addon);
}
|