From 6c575dc997829d120a1823640cf87d55014cd069 Mon Sep 17 00:00:00 2001 From: Vicente Ferrari Smith Date: Tue, 20 Jan 2026 22:55:02 +0100 Subject: [PATCH] c --- build.zig | 31 ++--- build.zig.zon | 4 + src/client/c.zig | 5 + src/client/font.zig | 111 +++++++++++------- src/client/main.zig | 276 ++++++++++++++++++++++++-------------------- 5 files changed, 249 insertions(+), 178 deletions(-) create mode 100644 src/client/c.zig diff --git a/build.zig b/build.zig index 7c71889..2693c9f 100644 --- a/build.zig +++ b/build.zig @@ -92,8 +92,7 @@ pub fn build(b: *std.Build) void { // 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.addImport("freetype", freetype_module); client.root_module.addCSourceFile(.{ .file = b.path("src/kb/kb_text_shape.h"), .language = .c, .flags = &.{"-DKB_TEXT_SHAPE_IMPLEMENTATION"} }); const kb_text_shape = b.addTranslateC(.{ @@ -131,20 +130,24 @@ pub fn build(b: *std.Build) void { client.root_module.addImport("bufzilla", bufzilla.module("bufzilla")); server.root_module.addImport("bufzilla", bufzilla.module("bufzilla")); - const raylib_dep = b.dependency("raylib_zig", .{ - .target = target, - .optimize = optimize, - }); + // const raylib_dep = b.dependency("raylib_zig", .{ + // .target = target, + // .optimize = optimize, + // }); - const raylib = raylib_dep.module("raylib"); // main raylib module - const raygui = raylib_dep.module("raygui"); // raygui module - const raylib_artifact = raylib_dep.artifact("raylib"); // raylib C library - raylib_artifact.root_module.addCMacro("SUPPORT_CUSTOM_FRAME_CONTROL", ""); + // const raylib = raylib_dep.module("raylib"); // main raylib module + // const raygui = raylib_dep.module("raygui"); // raygui module + // const raylib_artifact = raylib_dep.artifact("raylib"); // raylib C library + // raylib_artifact.root_module.addCMacro("SUPPORT_CUSTOM_FRAME_CONTROL", ""); - client.linkLibrary(raylib_artifact); - client.root_module.addImport("raylib", raylib); - client.root_module.addImport("raygui", raygui); - client.root_module.addImport("freetype", freetype_module); + // client.linkLibrary(raylib_artifact); + // client.root_module.addImport("raylib", raylib); + // client.root_module.addImport("raygui", raygui); + + const raylib_dep = b.dependency("raylib", .{ .target = target, .optimize = optimize }); + const raylib = raylib_dep.artifact("raylib"); + raylib.root_module.addCMacro("SUPPORT_CUSTOM_FRAME_CONTROL", ""); + client.linkLibrary(raylib); b.installArtifact(client); b.installArtifact(server); diff --git a/build.zig.zon b/build.zig.zon index 6dbf504..d036770 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -56,6 +56,10 @@ .url = "git+https://github.com/hexops/freetype#972cd37bccecae2cc9f54cf0b562263a13209d02", .hash = "freetype-0.0.0-AAAAAA5JcwBMujojfNLEq5g_WijZtU56mRLYx8bjjiMU", }, + .raylib = .{ + .url = "git+https://github.com/raysan5/raylib#29896a24039fb687d6ede44c63a78dd3b5829f8b", + .hash = "raylib-5.6.0-dev-whq8uM8HDQU5L4MyTYQJ2jJv9oFfadsWbEmuUEmXiPkq", + }, }, .paths = .{ "build.zig", diff --git a/src/client/c.zig b/src/client/c.zig new file mode 100644 index 0000000..3e17dcf --- /dev/null +++ b/src/client/c.zig @@ -0,0 +1,5 @@ +pub const c = @cImport({ + @cInclude("raylib.h"); + @cInclude("raymath.h"); + @cInclude("rlgl.h"); +}); diff --git a/src/client/font.zig b/src/client/font.zig index b54f4fd..8fbc5af 100644 --- a/src/client/font.zig +++ b/src/client/font.zig @@ -1,12 +1,13 @@ const std = @import("std"); - -const rl = @import("raylib"); +const c = @import("c.zig").c; +// const rl = @import("raylib"); const kb = @import("kb"); const ft = @import("freetype"); const rp = @import("stb_rect_pack"); pub var ft_lib : ft.Library = undefined; -pub var shader : rl.Shader = undefined; +pub var shader : c.Shader = undefined; +// pub var shader : rl.Shader = undefined; const ATLAS_SIZE = 4096; @@ -35,15 +36,18 @@ const Glyph = struct { descent : i32, // advance : i16, - st0 : rl.Vector2, - st1 : rl.Vector2, + st0 : c.Vector2, + st1 : c.Vector2, + // st0 : rl.Vector2, + // st1 : rl.Vector2, }; pub const Font = struct { face : ft.Face, glyphs : std.AutoHashMap(u32, Glyph), kb : kb.kbts_font, - texture : rl.Texture2D, + texture : c.Texture2D, + // texture : rl.Texture2D, font_data : []u8, pub fn init(filename : []const u8, size : i32, allocator: std.mem.Allocator) !Font { @@ -54,8 +58,9 @@ pub const Font = struct { var face = try ft_lib.createFaceMemory(font_data, 0); var glyphs = std.AutoHashMap(u32, Glyph).init(allocator); + try face.setCharSize(0, size * 64, 0, 72 * @as(u16, @intFromFloat(c.GetWindowScaleDPI().y))); // try face.setPixelSizes(0, @intCast(size)); - try face.setCharSize(0, size * 64, 0, 72 * @as(u16, @intFromFloat(rl.getWindowScaleDPI().y))); + // try face.setCharSize(0, size * 64, 0, 72 * @as(u16, @intFromFloat(rl.getWindowScaleDPI().y))); // try face.setCharSize(0, size * 64, 0, 72 * 1); try face.selectCharmap(.unicode); @@ -71,12 +76,13 @@ pub const Font = struct { defer allocator.free(_atlas); @memset(_atlas, 0); - const atlas : rl.Image = .{ + const atlas : c.Image = .{ + // const atlas : rl.Image = .{ .data = _atlas.ptr, .width = ATLAS_SIZE, .height = ATLAS_SIZE, .mipmaps = 1, - .format = .uncompressed_grayscale + .format = c.PIXELFORMAT_UNCOMPRESSED_GRAYSCALE, }; var iter = face.iterateCharmap(); @@ -167,7 +173,8 @@ pub const Font = struct { try glyphs.put(glyph.index, glyph); } - const texture = try rl.Texture.fromImage(atlas); + const texture = c.LoadTextureFromImage(atlas); + // const texture = try rl.Texture.fromImage(atlas); var _kb = kb.kbts_FontFromMemory(font_data.ptr, @intCast(font_data.len), 0, null, null); @@ -192,17 +199,21 @@ pub const Font = struct { self.glyphs.deinit(); self.face.deinit(); kb.kbts_FreeFont(&self.kb); - self.texture.unload(); + c.UnloadTexture(self.texture); + // self.texture.unload(); allocator.free(self.font_data); } pub fn render_text( self: *Font, text: []const u8, - pos: rl.Vector2, + pos: c.Vector2, + // pos: rl.Vector2, window_space: bool, - colour: rl.Color, - background: rl.Color, + colour: c.Color, + background: c.Color, + // colour: rl.Color, + // background: rl.Color, nice_background: bool, count_descent: bool ) void { @@ -212,10 +223,13 @@ pub const Font = struct { if (nice_background) { self.render_text( text, - pos.add(.{.x = 3.0, .y = -3.0}), + c.Vector2Add(pos, .{.x = 3.0, .y = -3.0}), + // pos.add(.{.x = 3.0, .y = -3.0}), window_space, - rl.Color.init(0, 0, 0, 255), - rl.Color.init(0, 0, 0, 0), + c.Color{ .r = 0, .g = 0, .b = 0, .a = 255 }, + c.Color{ .r = 0, .g = 0, .b = 0, .a = 0 }, + // rl.Color.init(0, 0, 0, 255), + // rl.Color.init(0, 0, 0, 0), false, false ); @@ -234,7 +248,8 @@ pub const Font = struct { render_pos.y += font_ascent; - rl.drawLine(@intFromFloat(render_pos.x), @intFromFloat(render_pos.y), rl.getScreenWidth(), @intFromFloat(render_pos.y), .red); + c.DrawLine(@intFromFloat(render_pos.x), @intFromFloat(render_pos.y), c.GetScreenWidth(), @intFromFloat(render_pos.y), c.RED); + // rl.drawLine(@intFromFloat(render_pos.x), @intFromFloat(render_pos.y), rl.getScreenWidth(), @intFromFloat(render_pos.y), .red); const Context = kb.kbts_CreateShapeContext(null, null); const kb_font = kb.kbts_ShapePushFont(Context, &self.kb); @@ -250,9 +265,12 @@ pub const Font = struct { var x_offset : f32 = 0; var y_offset : f32 = 0; - rl.beginShaderMode(shader); - rl.gl.rlSetTexture(self.texture.id); - rl.gl.rlBegin(rl.gl.rl_quads); + c.BeginShaderMode(shader); + c.rlSetTexture(self.texture.id); + c.rlBegin(c.RL_QUADS); + // rl.beginShaderMode(shader); + // rl.gl.rlSetTexture(self.texture.id); + // rl.gl.rlBegin(rl.gl.rl_quads); // Layout runs naively left to right. var Run = kb.kbts_run{}; @@ -277,16 +295,18 @@ pub const Font = struct { // glyph : *Glyph = table_find_pointer(*text.font.glyphs, RunGlyph.Id); if (self.glyphs.getPtr(RunGlyph.Id)) |glyph| { - var v0 = rl.Vector2.zero(); - var v1 = rl.Vector2.zero(); + var v0 = c.Vector2{}; + var v1 = c.Vector2{}; // const bx = @as(f32, @floatFromInt(glyph.bearing_x)); const by = @as(f32, @floatFromInt(glyph.bearing_y)); // const height = @as(f32, @floatFromInt(glyph.height)); // const descent = @as(f32, @floatFromInt(glyph.descent)); // const ascent = @as(f32, @floatFromInt(glyph.ascent)); // if (count_descent) { - v0 = render_pos.add(.{ .x = x_offset,// + glyph.bearing_x, + v0 = c.Vector2Add(render_pos, .{ .x = x_offset,// + glyph.bearing_x, .y = y_offset - by });// + draw_size.y });// /*- max_descent*/}; + // v0 = render_pos.add(.{ .x = x_offset,// + glyph.bearing_x, + // .y = y_offset - by });// + draw_size.y });// /*- max_descent*/}; // } else { // v0 = render_pos.add(.{ // .x = x_offset,// + glyph.bearing_x, @@ -294,9 +314,12 @@ pub const Font = struct { // });//* - glyph.height + draw_size.y*/}; // } - v1 = v0.add(rl.Vector2{ .x = @floatFromInt(glyph.width), .y = @floatFromInt(glyph.height) }); - const p0 : rl.Vector4 = .{ .x = v0.x, .y = v0.y, .z = 0.0, .w = 1.0 }; - const p1 : rl.Vector4 = .{ .x = v1.x, .y = v1.y, .z = 0.0, .w = 1.0 }; + v1 = c.Vector2Add(v0, c.Vector2{ .x = @floatFromInt(glyph.width), .y = @floatFromInt(glyph.height) }); + // v1 = v0.add(rl.Vector2{ .x = @floatFromInt(glyph.width), .y = @floatFromInt(glyph.height) }); + const p0 : c.Vector4 = .{ .x = v0.x, .y = v0.y, .z = 0.0, .w = 1.0 }; + const p1 : c.Vector4 = .{ .x = v1.x, .y = v1.y, .z = 0.0, .w = 1.0 }; + // const p0 : rl.Vector4 = .{ .x = v0.x, .y = v0.y, .z = 0.0, .w = 1.0 }; + // const p1 : rl.Vector4 = .{ .x = v1.x, .y = v1.y, .z = 0.0, .w = 1.0 }; x_offset += advance_x; y_offset += advance_y; @@ -316,13 +339,20 @@ pub const Font = struct { // t1 := t0 + .{cast(float, glyph.width / ATLAS_SIZE), cast(float, glyph.height / ATLAS_SIZE)}; // } - rl.gl.rlColor4ub(colour.r, colour.g, colour.b, colour.a); - rl.gl.rlNormal3f(0.0, 0.0, 1.0); + c.rlColor4ub(colour.r, colour.g, colour.b, colour.a); + c.rlNormal3f(0.0, 0.0, 1.0); - rl.gl.rlTexCoord2f(st0.x, st0.y); rl.gl.rlVertex2f(p0.x, p0.y); - rl.gl.rlTexCoord2f(st0.x, st1.y); rl.gl.rlVertex2f(p0.x, p1.y); - rl.gl.rlTexCoord2f(st1.x, st1.y); rl.gl.rlVertex2f(p1.x, p1.y); - rl.gl.rlTexCoord2f(st1.x, st0.y); rl.gl.rlVertex2f(p1.x, p0.y); + c.rlTexCoord2f(st0.x, st0.y); c.rlVertex2f(p0.x, p0.y); + c.rlTexCoord2f(st0.x, st1.y); c.rlVertex2f(p0.x, p1.y); + c.rlTexCoord2f(st1.x, st1.y); c.rlVertex2f(p1.x, p1.y); + c.rlTexCoord2f(st1.x, st0.y); c.rlVertex2f(p1.x, p0.y); + // rl.gl.rlColor4ub(colour.r, colour.g, colour.b, colour.a); + // rl.gl.rlNormal3f(0.0, 0.0, 1.0); + + // rl.gl.rlTexCoord2f(st0.x, st0.y); rl.gl.rlVertex2f(p0.x, p0.y); + // rl.gl.rlTexCoord2f(st0.x, st1.y); rl.gl.rlVertex2f(p0.x, p1.y); + // rl.gl.rlTexCoord2f(st1.x, st1.y); rl.gl.rlVertex2f(p1.x, p1.y); + // rl.gl.rlTexCoord2f(st1.x, st0.y); rl.gl.rlVertex2f(p1.x, p0.y); } else { x_offset += advance_x; y_offset += advance_y; @@ -331,26 +361,29 @@ pub const Font = struct { } } - rl.gl.rlEnd(); - rl.gl.rlSetTexture(0); - rl.endShaderMode(); + c.rlEnd(); + c.rlSetTexture(0); + c.EndShaderMode(); + // rl.gl.rlEnd(); + // rl.gl.rlSetTexture(0); + // rl.endShaderMode(); } - pub fn size_row(self: *Font, str: []const u8, n: i32, max_width: f32) struct {rl.Vector2, f32, i32} { + pub fn size_row(self: *Font, str: []const u8, n: i32, max_width: f32) struct {c.Vector2, f32, i32} { _ = max_width; _ = n; const Context = kb.kbts_CreateShapeContext(null, null); const kb_font = kb.kbts_ShapePushFont(Context, &self.kb); if (kb_font == null) { std.log.info("Could not open font!", .{}); - return .{ rl.Vector2.zero(), 0, 0 }; + return .{ c.Vector2.zero(), 0, 0 }; } kb.kbts_ShapeBegin(Context, kb.KBTS_DIRECTION_DONT_KNOW, kb.KBTS_LANGUAGE_DONT_KNOW); kb.kbts_ShapeUtf8(Context, str.ptr, @intCast(str.len), kb.KBTS_USER_ID_GENERATION_MODE_CODEPOINT_INDEX); kb.kbts_ShapeEnd(Context); - var size = rl.Vector2.zero(); + var size = c.Vector2.zero(); var max_descent : f32 = 0; // Layout runs naively left to right. diff --git a/src/client/main.zig b/src/client/main.zig index d932132..f238595 100644 --- a/src/client/main.zig +++ b/src/client/main.zig @@ -1,10 +1,12 @@ const std = @import("std"); const zm = @import("zmath"); const znet = @import("znet"); -const rl = @import("raylib"); +// const rl = @import("raylib"); const bufzilla = @import("bufzilla"); const ft = @import("freetype"); +const c = @import("c.zig").c; + const shared = @import("shared"); const client = @import("client.zig"); @@ -16,7 +18,7 @@ const dt : f32 = 1.0 / 200.0; var t : f32 = 0; var gt : f32 = 0; var accumulator : f32 = 0; -var k : f32 = 1.0; +var k : f32 = 1; var frame : i32 = 0; const screen_width = 1280; @@ -38,23 +40,30 @@ pub fn main() !void { defer _ = dbg_allocator.deinit(); try znet.init(); defer znet.deinit(); - rl.setConfigFlags(.{ .window_highdpi = true }); - rl.initWindow(screen_width, screen_height, "zzz"); - defer rl.closeWindow(); + c.SetConfigFlags(c.FLAG_WINDOW_HIGHDPI); + // rl.setConfigFlags(.{ .window_highdpi = true }); + c.InitWindow(screen_width, screen_height, "zzz"); + // rl.initWindow(screen_width, screen_height, "zzz"); + defer c.CloseWindow(); + // defer rl.closeWindow(); font.ft_lib = try ft.Library.init(); - std.log.debug("screen ? {}", .{rl.getScreenWidth()}); - std.log.debug("screen ? {}", .{rl.getScreenHeight()}); - std.log.debug("render ? {}", .{rl.getRenderWidth()}); - std.log.debug("render ? {}", .{rl.getRenderHeight()}); + // std.log.debug("screen ? {}", .{rl.getScreenWidth()}); + // std.log.debug("screen ? {}", .{rl.getScreenHeight()}); + // std.log.debug("render ? {}", .{rl.getRenderWidth()}); + // std.log.debug("render ? {}", .{rl.getRenderHeight()}); // std.log.debug("what's being used for viewport ? {}", .{rl.RLGL.State.framebufferWidth}); var f = try font.Font.init("assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf", 42, allocator); defer f.deinit(allocator); - font.shader = try rl.loadShader(null, "assets/text.frag"); + font.shader = c.LoadShader(null, "assets/text.frag"); + // const test_shader1 = try c.LoadShader(null, "assets/test_1.frag"); + // const test_shader2 = try c.LoadShader(null, "assets/test_2.frag"); + + // font.shader = try rl.loadShader(null, "assets/text.frag"); // const test_shader1 = try rl.loadShader(null, "assets/test_1.frag"); // const test_shader2 = try rl.loadShader(null, "assets/test_2.frag"); @@ -71,14 +80,14 @@ pub fn main() !void { }); defer host.deinit(); - const peer = try host.connect(.{ - .addr = try .init(.{ - .ip = .{ .ipv4 = "127.0.0.1" }, - .port = .{ .uint = 5000 }, - }), - .channel_limit = .max, - .data = 0, - }); + // const peer = try host.connect(.{ + // .addr = try .init(.{ + // .ip = .{ .ipv4 = "127.0.0.1" }, + // .port = .{ .uint = 5000 }, + // }), + // .channel_limit = .max, + // .data = 0, + // }); // connect() catch |err| switch (err) { // error.ConnectionRefused => { @@ -111,23 +120,26 @@ pub fn main() !void { // const camera = rl.Camera{ .fovy = 45, .position = .{ .x = 0, .y = 0, .z = 10 }, .projection = .perspective, .target = .{ .x = 0, .y = 0, .z = 0 }, .up = .{ .x = 0, .y = 1, .z = 0 } }; - rl.initAudioDevice(); + // rl.initAudioDevice(); - if (rl.isAudioDeviceReady()) { - std.log.info("audio device is ready!", .{}); - } else { - std.log.info("audio device is NOT ready!", .{}); - } + // if (rl.isAudioDeviceReady()) { + // std.log.info("audio device is ready!", .{}); + // } else { + // std.log.info("audio device is NOT ready!", .{}); + // } - const music = try rl.loadMusicStream("assets/romantic-piano-431010.mp3"); - std.log.info("{}", .{rl.isMusicValid(music)}); + // const music = try rl.loadMusicStream("assets/romantic-piano-431010.mp3"); + // std.log.info("{}", .{rl.isMusicValid(music)}); // rl.playMusicStream(music); - std.log.info("is music playing? {}", .{rl.isMusicStreamPlaying(music)}); + // std.log.info("is music playing? {}", .{rl.isMusicStreamPlaying(music)}); - var old_time : f32 = @floatCast(rl.getTime()); + var old_time : f32 = @floatCast(c.GetTime()); + // var old_time : f32 = @floatCast(rl.getTime()); - while (!rl.windowShouldClose()) { // Detect window close button or ESC key - const new_time : f32 = @floatCast(rl.getTime()); + while (!c.WindowShouldClose()) { + // while (!rl.windowShouldClose()) { // Detect window close button or ESC key + const new_time : f32 = @floatCast(c.GetTime()); + // const new_time : f32 = @floatCast(rl.getTime()); var frame_time = new_time - old_time; old_time = new_time; @@ -161,144 +173,158 @@ pub fn main() !void { }, }; - rl.pollInputEvents(); + c.PollInputEvents(); + // rl.pollInputEvents(); - if (peer.state() == .connected) { - const packet = try znet.Packet.init("Hello, Server!", 0, .reliable); - try peer.send(packet); - } - // _ = peer; + // if (peer.state() == .connected) { + // const packet = try znet.Packet.init("Hello, Server!", 0, .reliable); + // try peer.send(packet); + // } + // // _ = peer; - // Update - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- + // // Update + // //---------------------------------------------------------------------------------- + // // TODO: Update your variables here + // //---------------------------------------------------------------------------------- - rl.updateMusicStream(music); + // rl.updateMusicStream(music); - while (accumulator > dt * k) { - // update(dt * cast(float) k); - accumulator -= dt * k; - gt += dt * k; - } + // while (accumulator > dt * k) { + // // update(dt * cast(float) k); + // accumulator -= dt * k; + // gt += dt * k; + // } - // Draw - //---------------------------------------------------------------------------------- - rl.clearBackground(.black); + // // Draw + // //---------------------------------------------------------------------------------- + c.BeginDrawing(); + c.ClearBackground(c.SKYBLUE); + // rl.clearBackground(.black); - rl.beginDrawing(); + // rl.beginDrawing(); - // rl.drawRectangle(screen_width - 100, 0, 100, 100, .red); + // // rl.drawRectangle(screen_width - 100, 0, 100, 100, .red); f.render_text( "Whereas, disregard and contempt for human rights have resulted!", - rl.Vector2.init(0, 0), + c.Vector2{ .x = 0, .y = 0}, true, - rl.Color.white, - rl.Color.blank, + c.WHITE, + c.BLANK, false, true ); + // f.render_text( + // "Whereas, disregard and contempt for human rights have resulted!", + // rl.Vector2.init(0, 0), + // true, + // rl.Color.white, + // rl.Color.blank, + // false, + // true + // ); - // rl.beginShaderMode(test_shader1); - // rl.gl.rlBegin(rl.gl.rl_quads); + // // rl.beginShaderMode(test_shader1); + // // rl.gl.rlBegin(rl.gl.rl_quads); - // { - // const topLeft : rl.Vector2 = .{ .x = 0.0, .y = 0.0 }; - // const bottomRight : rl.Vector2 = .{ .x = @as(f32, @floatFromInt(rl.getScreenWidth())) / 2.0, .y = @as(f32, @floatFromInt(rl.getScreenHeight())) }; + // // { + // // const topLeft : rl.Vector2 = .{ .x = 0.0, .y = 0.0 }; + // // const bottomRight : rl.Vector2 = .{ .x = @as(f32, @floatFromInt(rl.getScreenWidth())) / 2.0, .y = @as(f32, @floatFromInt(rl.getScreenHeight())) }; - // rl.gl.rlVertex2f(topLeft.x, topLeft.y); - // rl.gl.rlVertex2f(topLeft.x, bottomRight.y); - // rl.gl.rlVertex2f(bottomRight.x, bottomRight.y); - // rl.gl.rlVertex2f(bottomRight.x, topLeft.y); + // // rl.gl.rlVertex2f(topLeft.x, topLeft.y); + // // rl.gl.rlVertex2f(topLeft.x, bottomRight.y); + // // rl.gl.rlVertex2f(bottomRight.x, bottomRight.y); + // // rl.gl.rlVertex2f(bottomRight.x, topLeft.y); - // } + // // } - // rl.gl.rlEnd(); - // rl.endShaderMode(); + // // rl.gl.rlEnd(); + // // rl.endShaderMode(); - // rl.beginShaderMode(test_shader2); - // rl.gl.rlBegin(rl.gl.rl_quads); + // // rl.beginShaderMode(test_shader2); + // // rl.gl.rlBegin(rl.gl.rl_quads); - // { - // const topLeft : rl.Vector2 = .{ .x = @as(f32, @floatFromInt(rl.getScreenWidth())) / 2.0, .y = 0 }; - // const bottomRight : rl.Vector2 = .{ .x = @floatFromInt(rl.getScreenWidth()), .y = @floatFromInt(rl.getScreenHeight()) }; + // // { + // // const topLeft : rl.Vector2 = .{ .x = @as(f32, @floatFromInt(rl.getScreenWidth())) / 2.0, .y = 0 }; + // // const bottomRight : rl.Vector2 = .{ .x = @floatFromInt(rl.getScreenWidth()), .y = @floatFromInt(rl.getScreenHeight()) }; - // rl.gl.rlVertex2f(topLeft.x, topLeft.y); - // rl.gl.rlVertex2f(topLeft.x, bottomRight.y); - // rl.gl.rlVertex2f(bottomRight.x, bottomRight.y); - // rl.gl.rlVertex2f(bottomRight.x, topLeft.y); - // } + // // rl.gl.rlVertex2f(topLeft.x, topLeft.y); + // // rl.gl.rlVertex2f(topLeft.x, bottomRight.y); + // // rl.gl.rlVertex2f(bottomRight.x, bottomRight.y); + // // rl.gl.rlVertex2f(bottomRight.x, topLeft.y); + // // } - // rl.gl.rlEnd(); - // rl.endShaderMode(); + // // rl.gl.rlEnd(); + // // rl.endShaderMode(); - // rl.beginShaderMode(test_shader2); - // rl.gl.rlBegin(rl.gl.rl_quads); + // // rl.beginShaderMode(test_shader2); + // // rl.gl.rlBegin(rl.gl.rl_quads); - // { - // const topLeft : rl.Vector2 = .{ .x = @as(f32, @floatFromInt(rl.getScreenWidth())) / 2.0, .y = 0 }; - // const bottomRight : rl.Vector2 = .{ .x = @floatFromInt(rl.getScreenWidth()), .y = @floatFromInt(rl.getScreenHeight()) }; + // // { + // // const topLeft : rl.Vector2 = .{ .x = @as(f32, @floatFromInt(rl.getScreenWidth())) / 2.0, .y = 0 }; + // // const bottomRight : rl.Vector2 = .{ .x = @floatFromInt(rl.getScreenWidth()), .y = @floatFromInt(rl.getScreenHeight()) }; - // rl.gl.rlVertex2f(topLeft.x, topLeft.y); - // rl.gl.rlVertex2f(topLeft.x, bottomRight.y); - // rl.gl.rlVertex2f(bottomRight.x, bottomRight.y); - // rl.gl.rlVertex2f(bottomRight.x, topLeft.y); - // } + // // rl.gl.rlVertex2f(topLeft.x, topLeft.y); + // // rl.gl.rlVertex2f(topLeft.x, bottomRight.y); + // // rl.gl.rlVertex2f(bottomRight.x, bottomRight.y); + // // rl.gl.rlVertex2f(bottomRight.x, topLeft.y); + // // } - // rl.gl.rlEnd(); - // rl.endShaderMode(); + // // rl.gl.rlEnd(); + // // rl.endShaderMode(); - // rl.drawRectangle(400, 0, 400, 450, rl.Color{ .r = 54, .g = 54, .b = 54, .a = 255 }); + // // rl.drawRectangle(400, 0, 400, 450, rl.Color{ .r = 54, .g = 54, .b = 54, .a = 255 }); - // f.texture.drawPro( - // .{.x = 0, .y = 0, .width = 4096, .height = 4096}, - // .{.x = 0, .y = 0, .width = 512, .height = 512 }, - // .zero(), 0, .white); + // // f.texture.drawPro( + // // .{.x = 0, .y = 0, .width = 4096, .height = 4096}, + // // .{.x = 0, .y = 0, .width = 512, .height = 512 }, + // // .zero(), 0, .white); - // const connected_text = "Connected"; - //const not_connected_text = "Not Connected"; + // // const connected_text = "Connected"; + // //const not_connected_text = "Not Connected"; - // switch (peer.state()) { - // .connected => rl.drawText(connected_text, @divFloor(rl.getScreenWidth(), 2) - @divFloor(rl.measureText(connected_text, f.baseSize), 2), 50, 20, .white), - // else => rl.drawText(not_connected_text, @divFloor(rl.getScreenWidth(), 2) - @divFloor(rl.measureText(not_connected_text, f.baseSize), 1), 50, 20, .white), - // } - //@divFloor(rl.getScreenWidth(), 2) - @divFloor(rl.measureText(connected_text, f.baseSize), 2), 50 + // // switch (peer.state()) { + // // .connected => rl.drawText(connected_text, @divFloor(rl.getScreenWidth(), 2) - @divFloor(rl.measureText(connected_text, f.baseSize), 2), 50, 20, .white), + // // else => rl.drawText(not_connected_text, @divFloor(rl.getScreenWidth(), 2) - @divFloor(rl.measureText(not_connected_text, f.baseSize), 1), 50, 20, .white), + // // } + // //@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); - // // 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); + // // // 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); + // //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); - //rl.drawRectangleLines(0, 0, 100, 100, .red); - // misc.drawFPS(0, 0, frame_time, frame); + // //rl.drawText("Congrats! You created your first window!", rl.getMouseX(), rl.getMouseY(), 20, .white); + // //rl.drawRectangleLines(0, 0, 100, 100, .red); + // // misc.drawFPS(0, 0, frame_time, frame); - //elf.draw(); + // //elf.draw(); - // rl.beginMode3D(camera); - // rl.drawSphere(.{ .x = 0, .y = 0, .z = 0 }, 1, .red); - // rl.endMode3D(); + // // rl.beginMode3D(camera); + // // rl.drawSphere(.{ .x = 0, .y = 0, .z = 0 }, 1, .red); + // // rl.endMode3D(); - rl.endDrawing(); + c.EndDrawing(); + // rl.endDrawing(); - //---------------------------------------------------------------------------------- + // //---------------------------------------------------------------------------------- - rl.swapScreenBuffer(); + c.SwapScreenBuffer(); + // rl.swapScreenBuffer(); } }