Compare commits
No commits in common. "603dc124dd7872ac62dffc08470bea1bd51cf9d1" and "e3f7ffa5e17b3109722114d1bde3cdd99bd75362" have entirely different histories.
603dc124dd
...
e3f7ffa5e1
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1 @@
|
||||||
/target
|
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
|
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -1,7 +0,0 @@
|
||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
version = 3
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "doggo"
|
|
||||||
version = "0.1.0"
|
|
|
@ -1,8 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "doggo"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
49
build.zig
Normal file
49
build.zig
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
const std = @import("std");
|
||||||
|
const raylib = @import("./3rdparty/raylib/src/build.zig");
|
||||||
|
|
||||||
|
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(.{});
|
||||||
|
|
||||||
|
// Standard release options allow the person running `zig build` to select
|
||||||
|
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
||||||
|
const mode = b.standardReleaseOptions();
|
||||||
|
|
||||||
|
const exe = b.addExecutable("doggo", "src/main.zig");
|
||||||
|
exe.setTarget(target);
|
||||||
|
|
||||||
|
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");
|
||||||
|
run_step.dependOn(&run_cmd.step);
|
||||||
|
|
||||||
|
const exe_tests = b.addTest("src/main.zig");
|
||||||
|
exe_tests.setTarget(target);
|
||||||
|
exe_tests.setBuildMode(mode);
|
||||||
|
|
||||||
|
const test_step = b.step("test", "Run unit tests");
|
||||||
|
test_step.dependOn(&exe_tests.step);
|
||||||
|
}
|
46
flake.lock
46
flake.lock
|
@ -1,63 +1,23 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"fenix": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
],
|
|
||||||
"rust-analyzer-src": "rust-analyzer-src"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1712211755,
|
|
||||||
"narHash": "sha256-KIJA4OvXFDXEeu7wstFDCxqZEfjaPQIowpzNww48TUw=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "fenix",
|
|
||||||
"rev": "39763c6e23a8423af316b85a74bad0cc5bc88d86",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "fenix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1712163089,
|
"lastModified": 1651369430,
|
||||||
"narHash": "sha256-Um+8kTIrC19vD4/lUCN9/cU9kcOsD1O1m+axJqQPyMM=",
|
"narHash": "sha256-d86uUm0s11exU9zLo2K1AwtJQJDKubFpoF0Iw767uT4=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "fd281bd6b7d3e32ddfa399853946f782553163b5",
|
"rev": "b283b64580d1872333a99af2b4cef91bb84580cf",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "nixpkgs",
|
"id": "nixpkgs",
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"fenix": "fenix",
|
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"rust-analyzer-src": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1712156296,
|
|
||||||
"narHash": "sha256-St7ZQrkrr5lmQX9wC1ZJAFxL8W7alswnyZk9d1se3Us=",
|
|
||||||
"owner": "rust-lang",
|
|
||||||
"repo": "rust-analyzer",
|
|
||||||
"rev": "8e581ac348e223488622f4d3003cb2bd412bf27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "rust-lang",
|
|
||||||
"ref": "nightly",
|
|
||||||
"repo": "rust-analyzer",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
55
flake.nix
55
flake.nix
|
@ -1,32 +1,41 @@
|
||||||
{
|
{
|
||||||
description = "Doggo flake";
|
description = "Doggo flake";
|
||||||
|
|
||||||
inputs = {
|
outputs = { self, nixpkgs }:
|
||||||
fenix = {
|
|
||||||
url = "github:nix-community/fenix";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs = { self, fenix, nixpkgs }:
|
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
|
|
||||||
|
# godot-alpha = (with pkgs; stdenv.mkDerivation {
|
||||||
|
# pname = "godot-alpha";
|
||||||
|
# version = "4.0.0-a8";
|
||||||
|
# src = fetchzip {
|
||||||
|
# url = "https://downloads.tuxfamily.org/godotengine/4.0/alpha8/Godot_v4.0-alpha8_linux.64.zip";
|
||||||
|
# hash = "sha512-qkUpt1reFgVDt5u9zLHYLoJAzC0D/YdtNpQhWLarpTW0e+Vzlqy7kna2plIeddybNsn+tS+QqTmYJExA7aT3zw==";
|
||||||
|
# };
|
||||||
|
# installPhase = ''
|
||||||
|
# mkdir -p $out/bin
|
||||||
|
# mv Godot_v4.0-alpha8_linux.64 $out/bin/godot-v4-alpha
|
||||||
|
# '';
|
||||||
|
# });
|
||||||
in {
|
in {
|
||||||
|
|
||||||
devShell.x86_64-linux = with pkgs;
|
devShell.x86_64-linux = with pkgs;
|
||||||
mkShell {
|
mkShell {
|
||||||
nativeBuildInputs = [
|
buildInputs = [
|
||||||
just
|
just
|
||||||
(fenix.packages.x86_64-linux.fromToolchainFile {
|
# zig
|
||||||
dir = ./.;
|
# godot
|
||||||
sha256 = "sha256-3St/9/UKo/6lz2Kfq2VmlzHyufduALpiIKaaKX4Pq0g=";
|
# godot-alpha
|
||||||
})
|
#
|
||||||
];
|
# xorg.libX11
|
||||||
|
# xorg.libXcursor
|
||||||
buildInputs = [
|
# xorg.libXi
|
||||||
];
|
# xorg.libXext
|
||||||
};
|
# xorg.libXrandr
|
||||||
|
# xorg.libXinerama
|
||||||
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;
|
# libGL
|
||||||
|
# libGLU
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
26
godot-impl/Main.gd
Normal file
26
godot-impl/Main.gd
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
extends Control
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
$HTTPRequest.connect("request_completed", self._on_request_completed)
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta):
|
||||||
|
var bodySize = $HTTPRequest.get_body_size()
|
||||||
|
var downloadedBytes = $HTTPRequest.get_downloaded_bytes()
|
||||||
|
|
||||||
|
var percent = downloadedBytes * 100 / bodySize
|
||||||
|
$Label.text = "Progress: %d %%" % percent
|
||||||
|
pass
|
||||||
|
|
||||||
|
func download_cpp_dap():
|
||||||
|
var url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz"
|
||||||
|
$HTTPRequest.download_file = "user://lldb.tar.xz"
|
||||||
|
$HTTPRequest.request(url)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_request_completed(result, response_code, headers, body):
|
||||||
|
# TODO: decompress archive
|
||||||
|
# OS.execute("")
|
||||||
|
pass
|
27
godot-impl/Main.tscn
Normal file
27
godot-impl/Main.tscn
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://cirquj62osi4v"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Main.gd" id="1_6lnje"]
|
||||||
|
|
||||||
|
[node name="Control" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
script = ExtResource( "1_6lnje" )
|
||||||
|
|
||||||
|
[node name="Button" type="Button" parent="."]
|
||||||
|
offset_left = 148.0
|
||||||
|
offset_top = 70.0
|
||||||
|
offset_right = 296.0
|
||||||
|
offset_bottom = 162.0
|
||||||
|
text = "Download C++ DAP (lldb)"
|
||||||
|
|
||||||
|
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
||||||
|
use_threads = true
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="."]
|
||||||
|
offset_left = 359.0
|
||||||
|
offset_top = 90.0
|
||||||
|
offset_right = 598.0
|
||||||
|
offset_bottom = 136.0
|
||||||
|
text = "Progress: 0%"
|
||||||
|
|
||||||
|
[connection signal="pressed" from="Button" to="." method="download_cpp_dap"]
|
BIN
godot-impl/icon.png
Normal file
BIN
godot-impl/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
34
godot-impl/icon.png.import
Normal file
34
godot-impl/icon.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dda5wstjh822x"
|
||||||
|
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://icon.png"
|
||||||
|
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
16
godot-impl/project.godot
Normal file
16
godot-impl/project.godot
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
; Engine configuration file.
|
||||||
|
; It's best edited using the editor UI and not directly,
|
||||||
|
; since the parameters that go here are not all obvious.
|
||||||
|
;
|
||||||
|
; Format:
|
||||||
|
; [section] ; section goes between []
|
||||||
|
; param=value ; assign values to parameters
|
||||||
|
|
||||||
|
config_version=5
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="Doggo"
|
||||||
|
run/main_scene="res://Main.tscn"
|
||||||
|
config/icon="res://icon.png"
|
||||||
|
config/features=PackedStringArray("4.0", "Vulkan Clustered")
|
26
justfile
26
justfile
|
@ -1,7 +1,21 @@
|
||||||
alias b := build
|
godot_project := "./godot-impl/project.godot"
|
||||||
build:
|
godot_url := "https://downloads.tuxfamily.org/godotengine/4.0/alpha8/Godot_v4.0-alpha8_linux.64.zip"
|
||||||
cargo build
|
godot_exe := "Godot_v4.0-alpha8_linux.64"
|
||||||
|
godot_exe_dir := "~/bin"
|
||||||
|
godot_path := godot_exe_dir + "/" + godot_exe
|
||||||
|
|
||||||
alias r := run
|
setup:
|
||||||
run:
|
#!/usr/bin/env bash
|
||||||
cargo run
|
set -euo pipefail
|
||||||
|
if [ ! -e {{godot_path}} ]; then
|
||||||
|
curl {{godot_url}} -O
|
||||||
|
unzip Godot*.zip
|
||||||
|
mv {{godot_exe}} {{godot_exe_dir}}
|
||||||
|
rm Godot*.zip
|
||||||
|
fi
|
||||||
|
|
||||||
|
#run:
|
||||||
|
# nixGL zig build run
|
||||||
|
|
||||||
|
edit: setup
|
||||||
|
{{godot_exe}} {{godot_project}}
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[toolchain]
|
|
||||||
channel = "stable"
|
|
||||||
profile = "default"
|
|
|
@ -1,3 +0,0 @@
|
||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
40
src/main.zig
Normal file
40
src/main.zig
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
const std = @import("std");
|
||||||
|
const r = @import("raylib.zig");
|
||||||
|
|
||||||
|
pub fn main() anyerror!void {
|
||||||
|
r.InitWindow(800, 450, "doggo");
|
||||||
|
defer r.CloseWindow();
|
||||||
|
|
||||||
|
// var selected_filename: [512]u8 = undefined;
|
||||||
|
var file_dialog_state = r.InitGuiFileDialog(420, 310, r.GetWorkingDirectory(), false);
|
||||||
|
|
||||||
|
while (!r.WindowShouldClose()) {
|
||||||
|
// Update
|
||||||
|
if (file_dialog_state.SelectFilePressed) {
|
||||||
|
std.log.info("{s} / {s}", .{ file_dialog_state.dirPathText, file_dialog_state.fileNameText });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
r.BeginDrawing();
|
||||||
|
defer r.EndDrawing();
|
||||||
|
|
||||||
|
r.ClearBackground(r.RAYWHITE);
|
||||||
|
r.DrawText("Congrats! You created your first window!", 190, 200, 20, r.LIGHTGRAY);
|
||||||
|
|
||||||
|
if (file_dialog_state.fileDialogActive) {
|
||||||
|
r.GuiLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r.GuiButton(r.Rectangle{ .x = 190, .y = 250, .width = 150, .height = 30 }, "Button")) {
|
||||||
|
std.log.info("Button pressed", .{});
|
||||||
|
file_dialog_state.fileDialogActive = true;
|
||||||
|
}
|
||||||
|
r.GuiUnlock();
|
||||||
|
|
||||||
|
r.GuiFileDialog(&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