Compare commits
No commits in common. "770ba3a9915214c590d0598572e110fa86eba69c" and "3c2fba5a1e66cd267c50437f4283ee6ca85a0fec" have entirely different histories.
770ba3a991
...
3c2fba5a1e
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
libraylib.a
|
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[submodule "3rdparty/raylib"]
|
||||||
|
path = 3rdparty/raylib
|
||||||
|
url = https://github.com/raysan5/raylib
|
||||||
|
[submodule "3rdparty/raygui"]
|
||||||
|
path = 3rdparty/raygui
|
||||||
|
url = https://github.com/raysan5/raygui.git
|
1
3rdparty/raygui
vendored
Submodule
1
3rdparty/raygui
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 865bb293764073c01e74314ef647464f1f10fd96
|
1
3rdparty/raylib
vendored
Submodule
1
3rdparty/raylib
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit ca12ef48e9e9f4eae03b1ca43ec3eb0a78d63dd3
|
53
build.zig
53
build.zig
|
@ -1,29 +1,48 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const capy = @import("capy");
|
const raylib = @import("./3rdparty/raylib/src/build.zig");
|
||||||
|
|
||||||
pub fn build(b: *std.Build) !void {
|
pub fn build(b: *std.build.Builder) void {
|
||||||
|
// Standard target options allows the person running `zig build` to choose
|
||||||
|
// what target to build for. Here we do not override the defaults, which
|
||||||
|
// means any target is allowed, and the default is native. Other options
|
||||||
|
// for restricting supported target set are available.
|
||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const mode = b.standardOptimizeOption(.{});
|
|
||||||
|
|
||||||
const exe = b.addExecutable(.{
|
// Standard release options allow the person running `zig build` to select
|
||||||
.name = "doggo",
|
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
const mode = b.standardReleaseOptions();
|
||||||
.target = target,
|
|
||||||
.optimize = mode,
|
|
||||||
});
|
|
||||||
|
|
||||||
b.installArtifact(exe);
|
const exe = b.addExecutable("doggo", "src/main.zig");
|
||||||
|
exe.setTarget(target);
|
||||||
|
|
||||||
const run_cmd = try capy.install(exe, .{ .args = b.args });
|
const ray = raylib.addRaylib(b, exe.target);
|
||||||
|
exe.linkLibrary(ray);
|
||||||
|
exe.addIncludeDir("3rdparty/raylib/src");
|
||||||
|
exe.addIncludeDir("3rdparty/raygui/src");
|
||||||
|
exe.addIncludeDir("3rdparty/raygui/examples");
|
||||||
|
const raylib_flags = &[_][]const u8{
|
||||||
|
"-std=gnu99",
|
||||||
|
"-DPLATFORM_DESKTOP",
|
||||||
|
"-DGL_SILENCE_DEPRECATION=199309L",
|
||||||
|
"-fno-sanitize=undefined",
|
||||||
|
};
|
||||||
|
exe.addCSourceFile("src/raylib.c", raylib_flags);
|
||||||
|
|
||||||
|
exe.setBuildMode(mode);
|
||||||
|
exe.install();
|
||||||
|
|
||||||
|
const run_cmd = exe.run();
|
||||||
|
run_cmd.step.dependOn(b.getInstallStep());
|
||||||
|
if (b.args) |args| {
|
||||||
|
run_cmd.addArgs(args);
|
||||||
|
}
|
||||||
|
|
||||||
const run_step = b.step("run", "Run the app");
|
const run_step = b.step("run", "Run the app");
|
||||||
run_step.dependOn(run_cmd);
|
run_step.dependOn(&run_cmd.step);
|
||||||
|
|
||||||
const exe_tests = b.addTest(.{
|
const exe_tests = b.addTest("src/main.zig");
|
||||||
.root_source_file = .{ .path = "src/main.zig" },
|
exe_tests.setTarget(target);
|
||||||
.target = target,
|
exe_tests.setBuildMode(mode);
|
||||||
.optimize = mode,
|
|
||||||
});
|
|
||||||
|
|
||||||
const test_step = b.step("test", "Run unit tests");
|
const test_step = b.step("test", "Run unit tests");
|
||||||
test_step.dependOn(&exe_tests.step);
|
test_step.dependOn(&exe_tests.step);
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
.{
|
|
||||||
.name = "doggo",
|
|
||||||
.version = "0.1.0",
|
|
||||||
.paths = .{
|
|
||||||
"build.zig",
|
|
||||||
"build.zig.zon",
|
|
||||||
"src",
|
|
||||||
},
|
|
||||||
.dependencies = .{
|
|
||||||
.capy = .{
|
|
||||||
.url = "https://github.com/ffreling/capy/archive/refs/heads/zig-0.12.0.tar.gz",
|
|
||||||
.hash = "12207fd2f0d02eb929d1e8a05843de4dc3f4b362055e9e47a014fb6b806a592d9808",
|
|
||||||
},
|
|
||||||
.zigimg = .{
|
|
||||||
.url = "https://github.com/zigimg/zigimg/archive/8873f29fc449e1b63400e9f4ad86d3c76204f962.tar.gz",
|
|
||||||
.hash = "122019f6439545235af116d0d8eb81fde1ff05fdb070da57c723772c557f84c5bf39",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1714750952,
|
"lastModified": 1651369430,
|
||||||
"narHash": "sha256-oOUdvPrO8CbupgDSaPou+Jv6GL+uQA2QlE33D7OLzkM=",
|
"narHash": "sha256-d86uUm0s11exU9zLo2K1AwtJQJDKubFpoF0Iw767uT4=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "5fd8536a9a5932d4ae8de52b7dc08d92041237fc",
|
"rev": "b283b64580d1872333a99af2b4cef91bb84580cf",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
19
flake.nix
19
flake.nix
|
@ -4,15 +4,24 @@
|
||||||
outputs = { self, nixpkgs }:
|
outputs = { self, nixpkgs }:
|
||||||
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
in {
|
in {
|
||||||
|
# packages.x86_64-linux.hello = pkgs.hello;
|
||||||
|
# packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
|
||||||
|
# defaultPackage.x86_64-linux = self.packages.x86_64-linux.hello;
|
||||||
|
|
||||||
devShell.x86_64-linux = with pkgs;
|
devShell.x86_64-linux = with pkgs;
|
||||||
mkShell {
|
mkShell {
|
||||||
nativeBuildInputs = [
|
buildInputs = [
|
||||||
just
|
just
|
||||||
zig
|
zig
|
||||||
zls
|
|
||||||
];
|
xorg.libX11
|
||||||
buildInputs = [
|
xorg.libXcursor
|
||||||
gtk4
|
xorg.libXi
|
||||||
|
xorg.libXext
|
||||||
|
xorg.libXrandr
|
||||||
|
xorg.libXinerama
|
||||||
|
libGL
|
||||||
|
libGLU
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
7
justfile
7
justfile
|
@ -1,7 +1,2 @@
|
||||||
alias b := build
|
|
||||||
build:
|
|
||||||
zig build
|
|
||||||
|
|
||||||
alias r := run
|
|
||||||
run:
|
run:
|
||||||
zig build run
|
nixGL zig build run
|
||||||
|
|
79
src/main.zig
79
src/main.zig
|
@ -1,61 +1,40 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const capy = @import("capy");
|
const r = @import("raylib.zig");
|
||||||
|
|
||||||
// This is required for your app to build to WebAssembly and other particular architectures
|
pub fn main() anyerror!void {
|
||||||
pub usingnamespace capy.cross_platform;
|
r.InitWindow(800, 450, "doggo");
|
||||||
|
defer r.CloseWindow();
|
||||||
|
|
||||||
pub fn main() !void {
|
// var selected_filename: [512]u8 = undefined;
|
||||||
try capy.backend.init();
|
var file_dialog_state = r.InitGuiFileDialog(420, 310, r.GetWorkingDirectory(), false);
|
||||||
|
|
||||||
var window = try capy.Window.init();
|
while (!r.WindowShouldClose()) {
|
||||||
try window.set(
|
// Update
|
||||||
capy.label(.{ .text = "Hello, World", .alignment = .Center }),
|
if (file_dialog_state.SelectFilePressed) {
|
||||||
);
|
std.log.info("{s} / {s}", .{ file_dialog_state.dirPathText, file_dialog_state.fileNameText });
|
||||||
|
|
||||||
window.setTitle("Hello");
|
|
||||||
window.setPreferredSize(250, 100);
|
|
||||||
window.show();
|
|
||||||
|
|
||||||
capy.runEventLoop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// const std = @import("std");
|
// Draw
|
||||||
// const r = @import("raylib.zig");
|
r.BeginDrawing();
|
||||||
|
defer r.EndDrawing();
|
||||||
|
|
||||||
// pub fn main() anyerror!void {
|
r.ClearBackground(r.RAYWHITE);
|
||||||
// r.InitWindow(800, 450, "doggo");
|
r.DrawText("Congrats! You created your first window!", 190, 200, 20, r.LIGHTGRAY);
|
||||||
// defer r.CloseWindow();
|
|
||||||
|
|
||||||
// // var selected_filename: [512]u8 = undefined;
|
if (file_dialog_state.fileDialogActive) {
|
||||||
// var file_dialog_state = r.InitGuiWindowFileDialog(r.GetWorkingDirectory());
|
r.GuiLock();
|
||||||
|
}
|
||||||
|
|
||||||
// while (!r.WindowShouldClose()) {
|
if (r.GuiButton(r.Rectangle{ .x = 190, .y = 250, .width = 150, .height = 30 }, "Button")) {
|
||||||
// // Update
|
std.log.info("Button pressed", .{});
|
||||||
// if (file_dialog_state.SelectFilePressed) {
|
file_dialog_state.fileDialogActive = true;
|
||||||
// std.log.info("{s} / {s}", .{ file_dialog_state.dirPathText, file_dialog_state.fileNameText });
|
}
|
||||||
// }
|
r.GuiUnlock();
|
||||||
|
|
||||||
// // Draw
|
r.GuiFileDialog(&file_dialog_state);
|
||||||
// r.BeginDrawing();
|
}
|
||||||
// defer r.EndDrawing();
|
}
|
||||||
|
|
||||||
// r.ClearBackground(r.RAYWHITE);
|
test "basic test" {
|
||||||
// r.DrawText("Congrats! You created your first window!", 190, 200, 20, r.LIGHTGRAY);
|
try std.testing.expectEqual(10, 3 + 7);
|
||||||
|
}
|
||||||
// if (file_dialog_state.windowActive) {
|
|
||||||
// r.GuiLock();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (r.GuiButton(r.Rectangle{ .x = 190, .y = 250, .width = 150, .height = 30 }, "Button") == 1) {
|
|
||||||
// std.log.info("Button pressed", .{});
|
|
||||||
// file_dialog_state.windowActive = true;
|
|
||||||
// }
|
|
||||||
// r.GuiUnlock();
|
|
||||||
|
|
||||||
// r.GuiWindowFileDialog(&file_dialog_state);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// test "basic test" {
|
|
||||||
// try std.testing.expectEqual(10, 3 + 7);
|
|
||||||
// }
|
|
||||||
|
|
6
src/raylib.c
Normal file
6
src/raylib.c
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#define RAYGUI_IMPLEMENTATION
|
||||||
|
#include <raygui.h>
|
||||||
|
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
|
||||||
|
|
||||||
|
#define GUI_FILE_DIALOG_IMPLEMENTATION
|
||||||
|
#include <custom_file_dialog/gui_file_dialog.h>
|
5
src/raylib.zig
Normal file
5
src/raylib.zig
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
pub usingnamespace @cImport({
|
||||||
|
@cInclude("raylib.h");
|
||||||
|
@cInclude("raygui.h");
|
||||||
|
@cInclude("custom_file_dialog/gui_file_dialog.h");
|
||||||
|
});
|
Loading…
Reference in a new issue