Adding support for raygui (#95)

* updated build.zig and generate_functions.py to add raygui

* added raygui.h and manually coded some structs & enums in raygui prelude WIP

* ported all the structs, enums and globals to zig till raygui implementation

* imported types from raylib in raygui

* re-encoded raygui-prelude.zig. I don't know for some reason it was showing up as UTF-16 unicode text file. re-encoded it to UTF-8

* fixed imports in prelude to work properly with generated files

* updated generate_functions.py file to generate for raygui [text type error not fixed]

* simple temporary patch for mentioned text type issue

* removed unused imports from raylib in raygui

* added generated files

* Manually define raygui functions for slice arguments

* Manually define raygui functions with pointer return values

---------

Co-authored-by: Not-Nik <nik.wipper@gmx.de>
This commit is contained in:
Mohanavel S K 2024-05-31 22:54:05 +05:30 committed by GitHub
parent 39909cdcb3
commit efb7b736db
Failed to generate hash of commit
7 changed files with 6874 additions and 2 deletions

View file

@ -146,6 +146,18 @@ const gl = struct {
}
};
const gui = struct {
fn getModule(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.Mode) *std.Build.Module {
const raylib = rl.getModule(b, target, optimize);
return b.addModule("raygui", .{
.root_source_file = b.path("lib/raygui.zig"),
.imports = &.{.{ .name = "raylib-zig", .module = raylib }},
.target = target,
.optimize = optimize,
});
}
};
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
@ -248,6 +260,7 @@ pub fn build(b: *std.Build) !void {
const raylib = rl.getModule(b, target, optimize);
const raylib_math = rl.math.getModule(b, target, optimize);
const rlgl = rl.gl.getModule(b, target, optimize);
const raygui = rl.gui.getModule(b, target, optimize);
const raylib_test = b.addTest(.{
.root_source_file = b.path("lib/raylib.zig"),
@ -269,10 +282,18 @@ pub fn build(b: *std.Build) !void {
});
rlgl_test.root_module.addImport("raylib-zig", raylib);
const raygui_test = b.addTest(.{
.root_source_file = b.path("lib/raygui.zig"),
.target = target,
.optimize = optimize,
});
raygui_test.root_module.addImport("raylib-zig", raylib);
const test_step = b.step("test", "Check for library compilation errors");
test_step.dependOn(&raylib_test.step);
test_step.dependOn(&raylib_math_test.step);
test_step.dependOn(&rlgl_test.step);
test_step.dependOn(&raygui_test.step);
const examples_step = b.step("examples", "Builds all the examples");
@ -282,6 +303,7 @@ pub fn build(b: *std.Build) !void {
exe_lib.root_module.addImport("raylib", raylib);
exe_lib.root_module.addImport("raylib-math", raylib_math);
exe_lib.root_module.addImport("rlgl", rlgl);
exe_lib.root_module.addImport("raygui", raygui);
const raylib_lib = getRaylib(b, target, optimize, options);
// Note that raylib itself isn't actually added to the exe_lib
@ -308,6 +330,7 @@ pub fn build(b: *std.Build) !void {
exe.root_module.addImport("raylib", raylib);
exe.root_module.addImport("raylib-math", raylib_math);
exe.root_module.addImport("rlgl", rlgl);
exe.root_module.addImport("raygui", raygui);
const run_cmd = b.addRunArtifact(exe);
const run_step = b.step(ex.name, ex.desc);