just add everything!

This commit is contained in:
Vicente Ferrari Smith 2026-01-13 22:52:26 +01:00
parent d639db711f
commit e439198097
5 changed files with 1973 additions and 19 deletions

View File

@ -23,5 +23,5 @@ void main()
// float x = fract(fragTexCoord.s);
// float final = smoothstep(divider - 0.1, divider + 0.1, x);
finalColor = vec4(fragTexCoord, 0.0, 1.0);
finalColor = fragColor;
}

View File

@ -76,6 +76,22 @@ pub fn build(b: *std.Build) void {
}),
});
const freetype_module = b.addModule("mach-freetype", .{
.root_source_file = b.path("src/freetype/freetype.zig"),
});
if (b.lazyDependency("freetype", .{
.target = target,
.optimize = optimize,
.use_system_zlib = false,
.enable_brotli = false,
})) |dep| {
// freetype_tests.root_module.linkLibrary(dep.artifact("freetype"));
freetype_module.linkLibrary(dep.artifact("freetype"));
// harfbuzz_module.linkLibrary(dep.artifact("freetype"));
// harfbuzz_tests.root_module.linkLibrary(dep.artifact("freetype"));
}
// client.addCSourceFile(.{ .file = b.path("src/kb/kb_text_shape.h"), .language = .c, .flags = &.{"-DKB_TEXT_SHAPE_IMPLEMENTATION"} });
client.root_module.addCSourceFile(.{ .file = b.path("src/kb/kb_text_shape.h"), .language = .c, .flags = &.{"-DKB_TEXT_SHAPE_IMPLEMENTATION"} });
@ -120,6 +136,7 @@ pub fn build(b: *std.Build) void {
client.linkLibrary(raylib_artifact);
client.root_module.addImport("raylib", raylib);
client.root_module.addImport("raygui", raygui);
client.root_module.addImport("freetype", freetype_module);
b.installArtifact(client);
b.installArtifact(server);

View File

@ -52,6 +52,10 @@
.url = "https://github.com/theseyan/bufzilla/archive/refs/tags/v0.3.2.tar.gz",
.hash = "bufzilla-0.3.0-gU6dXi67AQAg3WIFrNQ0iafrvexj3iBwVcczrVzrN3Ir",
},
.freetype = .{
.url = "git+https://github.com/hexops/freetype#972cd37bccecae2cc9f54cf0b562263a13209d02",
.hash = "freetype-0.0.0-AAAAAA5JcwBMujojfNLEq5g_WijZtU56mRLYx8bjjiMU",
},
},
.paths = .{
"build.zig",

View File

@ -6,6 +6,7 @@ const bufzilla = @import("bufzilla");
const shared = @import("shared");
const kb = @import("kb");
const ft = @import("freetype");
const client = @import("client.zig");
const entity = @import("entity.zig");
@ -41,13 +42,15 @@ pub fn main() !void {
// kbts_shape_context *Context = kbts_CreateShapeContext(0, 0);
_ = try ft.Library.init();
_ = kb.kbts_CreateShapeContext(null, null);
const shader = try rl.loadShader(null, "assets/test.frag");
// const shader = try rl.loadShader(null, "assets/test.frag");
const img = rl.genImageColor(32, 32, .blank);
const tx = try rl.loadTextureFromImage(img);
rl.unloadImage(img);
// const img = rl.genImageColor(32, 32, .blank);
// const tx = try rl.loadTextureFromImage(img);
// rl.unloadImage(img);
const host = try znet.Host.init(.{
.addr = null,
@ -177,6 +180,29 @@ pub fn main() !void {
rl.beginDrawing();
// rl.beginShaderMode(shader);
rl.gl.rlBegin(rl.gl.rl_triangles);
// const color = rl.Color.init(255, 0, 255, 255);
const top : rl.Vector2 = .{ .x = @as(f32, @floatFromInt(rl.getScreenWidth())) / 2.0, .y = 0.0 };
const bottomLeft : rl.Vector2 = .{ .x = 0.0, .y = @floatFromInt(rl.getScreenHeight()) };
const bottomRight : rl.Vector2 = .{ .x = @floatFromInt(rl.getScreenWidth()), .y = @floatFromInt(rl.getScreenHeight()) };
// rl.gl.vertex
rl.gl.rlColor4ub(0, 255, 0, 255);
rl.gl.rlVertex2f(top.x, top.y);
rl.gl.rlColor4ub(255, 0, 0, 255);
rl.gl.rlVertex2f(bottomLeft.x, bottomLeft.y);
rl.gl.rlColor4ub(0, 0, 255, 255);
rl.gl.rlVertex2f(bottomRight.x, bottomRight.y);
// rl.gl.rlVertex2f(topRight.x, topRight.y);
// rl.gl.rlVertex2f(bottomLeft.x, bottomLeft.y);
// rl.gl.rlVertex2f(bottomRight.x, bottomRight.y);
rl.gl.rlEnd();
// rl.endShaderMode();
// const connected_text = "Connected";
//const not_connected_text = "Not Connected";
@ -187,21 +213,20 @@ pub fn main() !void {
//@divFloor(rl.getScreenWidth(), 2) - @divFloor(rl.measureText(connected_text, f.baseSize), 2), 50
rl.beginShaderMode(shader);
// const font_size : i32 = 180;
// const text_size = rl.Vector2{.x = @floatFromInt(rl.measureText(connected_text, font_size)), .y = font_size};//rl.measureTextEx(try rl.getFontDefault(), connected_text, font_size, font_size / 10);
// const pos = rl.Vector2{.x = 0, .y = 0};
// rl.drawText(connected_text, pos.x, pos.y, font_size, .white);
// rl.drawRectangleLines(pos.x, pos.y, @intFromFloat(text_size.x), @intFromFloat(text_size.y), .red);
// rl.drawRectangle(pos.x, pos.y, rl.getScreenWidth(), rl.getScreenHeight(), .white);
rl.drawTexturePro(tx,
rl.Rectangle{.x = 0, .y = 0, .width = 32, .height = 32},
rl.Rectangle{.x = 100, .y = 100, .width = 500, .height = 500},
.{.x = 0, .y = 0},
0,
.white);
rl.endShaderMode();
// // const font_size : i32 = 180;
// // const text_size = rl.Vector2{.x = @floatFromInt(rl.measureText(connected_text, font_size)), .y = font_size};//rl.measureTextEx(try rl.getFontDefault(), connected_text, font_size, font_size / 10);
// // const pos = rl.Vector2{.x = 0, .y = 0};
// // rl.drawText(connected_text, pos.x, pos.y, font_size, .white);
// // rl.drawRectangleLines(pos.x, pos.y, @intFromFloat(text_size.x), @intFromFloat(text_size.y), .red);
// // rl.drawRectangle(pos.x, pos.y, rl.getScreenWidth(), rl.getScreenHeight(), .white);
// rl.drawTexturePro(tx,
// rl.Rectangle{.x = 0, .y = 0, .width = 32, .height = 32},
// rl.Rectangle{.x = 100, .y = 100, .width = 500, .height = 500},
// .{.x = 0, .y = 0},
// 0,
// .white);
//rl.drawLineV(.{.x = @floatFromInt(@divFloor(rl.getScreenWidth(), 2)), .y = 0}, .{.x = @floatFromInt(@divFloor(rl.getScreenWidth(), 2)), .y = @floatFromInt(rl.getScreenHeight())}, .red);

1908
src/freetype/freetype.zig Normal file

File diff suppressed because it is too large Load Diff