day end
This commit is contained in:
parent
561caf560b
commit
d45a70adcf
18
main.zig
18
main.zig
@ -71,7 +71,6 @@ fn getTermDimension() !Winsize {
|
||||
}
|
||||
|
||||
fn getNum(str1: []const u8) []u64 {
|
||||
//_ = str1;
|
||||
var pos: u64 = 0;
|
||||
var num = std.mem.zeroes([64]u64);
|
||||
var num_res = std.mem.zeroes([16]u64);
|
||||
@ -137,6 +136,7 @@ fn fillBuffer() !void {
|
||||
w = try getTermDimension();
|
||||
buffer_size = w.ws_row;
|
||||
buffer_size = buffer_size * w.ws_col * 4;
|
||||
|
||||
var buffer = try allocator.alloc(u8, buffer_size); //utf-8 can be 4 bytes long
|
||||
defer allocator.free(buffer);
|
||||
|
||||
@ -151,10 +151,11 @@ fn fillBuffer() !void {
|
||||
.c = Point{ .x = 30, .y = 1, .z = 0, .direction = .{ .x = 1, .y = 1, .z = 1 } },
|
||||
};
|
||||
|
||||
//clear buffer
|
||||
//video loop
|
||||
while (true) {
|
||||
buffer[0] = 0;
|
||||
i = 0;
|
||||
//clear buffer
|
||||
while (i < buffer.len) : (i += 4) {
|
||||
slice = buffer[i .. i + 4];
|
||||
bytes_written = try std.unicode.utf8Encode(' ', slice);
|
||||
@ -322,7 +323,14 @@ fn bresenham(buf: []u8, w: Winsize, p1: Point, p2: Point) !void {
|
||||
}
|
||||
|
||||
fn triangle(buffer: []u8, w: Winsize, vec: Vec3) !void {
|
||||
_ = try bresenham(buffer, w, vec.a, vec.b);
|
||||
_ = try bresenham(buffer, w, vec.b, vec.c);
|
||||
_ = try bresenham(buffer, w, vec.c, vec.a);
|
||||
var vec_fill: Vec3 = vec;
|
||||
try bresenham(buffer, w, vec.a, vec.b);
|
||||
try bresenham(buffer, w, vec.b, vec.c);
|
||||
try bresenham(buffer, w, vec.c, vec.a);
|
||||
while (vec_fill.a.y < vec.c.y) : (vec_fill.a.y += 1) {
|
||||
try bresenham(buffer, w, vec_fill.a, vec.b);
|
||||
}
|
||||
while (vec_fill.a.y > vec.c.y) : (vec_fill.a.y -= 1) {
|
||||
try bresenham(buffer, w, vec_fill.a, vec.b);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user