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
38
39
40
41
42
|
//! Framebuffer video operations
const boot = @import("../../boot/multiboot/multiboot.zig");
const pixel = @import("../../utils/graphics/pixel.zig");
var fb: ?boot.FramebufferInfo = null;
pub fn init(framebuffer: boot.FramebufferInfo) void {
fb = framebuffer;
}
pub fn clear(c: u32) void {
if (fb) |f| {
pixel.fill(f, c);
}
}
pub fn put_pixel(x: u32, y: u32, c: u32) void {
if (fb) |f| {
pixel.put(f, x, y, c);
}
}
pub fn fill_rect(x: u32, y: u32, w: u32, h: u32, c: u32) void {
if (fb) |f| {
pixel.fill_rect(f, x, y, w, h, c);
}
}
pub fn get_width() u32 {
if (fb) |f| return f.width;
return 0;
}
pub fn get_height() u32 {
if (fb) |f| return f.height;
return 0;
}
pub fn get_framebuffer() ?boot.FramebufferInfo {
return fb;
}
|