custom shader

This commit is contained in:
vfs committed 2026-01-13 20:18:47 +01:00
1 parent a797b13b8e
commit d639db711f
4 files changed
+94 -11

No files matched your search

+28 -9
View File
@@ -4,9 +4,8 @@ const znet = @import("znet");
const rl = @import("raylib");
const bufzilla = @import("bufzilla");
const c = @cImport(@cInclude("../kb/kb_text_shape.h"));
const shared = @import("shared");
const kb = @import("kb");
const client = @import("client.zig");
const entity = @import("entity.zig");
@@ -40,6 +39,16 @@ pub fn main() !void {
rl.initWindow(1280, 720, "zzz");
defer rl.closeWindow();
// kbts_shape_context *Context = kbts_CreateShapeContext(0, 0);
_ = kb.kbts_CreateShapeContext(null, null);
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 host = try znet.Host.init(.{
.addr = null,
.peer_limit = 1,
@@ -168,7 +177,7 @@ pub fn main() !void {
rl.beginDrawing();
const connected_text = "Connected";
// const connected_text = "Connected";
//const not_connected_text = "Not Connected";
// switch (peer.state()) {
@@ -177,13 +186,23 @@ pub fn main() !void {
// }
//@divFloor(rl.getScreenWidth(), 2) - @divFloor(rl.measureText(connected_text, f.baseSize), 2), 50
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);
std.log.info("text size: {}", .{text_size});
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();
//rl.drawLineV(.{.x = @floatFromInt(@divFloor(rl.getScreenWidth(), 2)), .y = 0}, .{.x = @floatFromInt(@divFloor(rl.getScreenWidth(), 2)), .y = @floatFromInt(rl.getScreenHeight())}, .red);
//rl.drawText("Congrats! You created your first window!", rl.getMouseX(), rl.getMouseY(), 20, .white);