commit 808b72c030abeedf102a448da91bdf3be754611a Author: Skye Date: Mon Jan 16 21:19:14 2023 +0900 first commit diff --git a/.import/.gdignore b/.import/.gdignore new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.import/.gdignore @@ -0,0 +1 @@ + diff --git a/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 new file mode 100644 index 0000000..5328bc7 --- /dev/null +++ b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 @@ -0,0 +1,3 @@ +source_md5="47313fa4c47a9963fddd764e1ec6e4a8" +dest_md5="26ea799ea0a3da9e753b3ebe822e0570" + diff --git a/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex new file mode 100644 index 0000000..71f6913 Binary files /dev/null and b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex differ diff --git a/.import/rustgodottest.apple-touch-icon.png-ec42c4e60f08191988a15abdcdacae16.md5 b/.import/rustgodottest.apple-touch-icon.png-ec42c4e60f08191988a15abdcdacae16.md5 new file mode 100644 index 0000000..3095a7a --- /dev/null +++ b/.import/rustgodottest.apple-touch-icon.png-ec42c4e60f08191988a15abdcdacae16.md5 @@ -0,0 +1,3 @@ +source_md5="cf4aec4842e6f28b128d15ef58be76d0" +dest_md5="f713b52cc8973914be7fa878566b7e90" + diff --git a/.import/rustgodottest.apple-touch-icon.png-ec42c4e60f08191988a15abdcdacae16.stex b/.import/rustgodottest.apple-touch-icon.png-ec42c4e60f08191988a15abdcdacae16.stex new file mode 100644 index 0000000..11c0ee6 Binary files /dev/null and b/.import/rustgodottest.apple-touch-icon.png-ec42c4e60f08191988a15abdcdacae16.stex differ diff --git a/.import/rustgodottest.icon.png-d56bcdfb783f4fb63ef0fbffd631b690.md5 b/.import/rustgodottest.icon.png-d56bcdfb783f4fb63ef0fbffd631b690.md5 new file mode 100644 index 0000000..5328bc7 --- /dev/null +++ b/.import/rustgodottest.icon.png-d56bcdfb783f4fb63ef0fbffd631b690.md5 @@ -0,0 +1,3 @@ +source_md5="47313fa4c47a9963fddd764e1ec6e4a8" +dest_md5="26ea799ea0a3da9e753b3ebe822e0570" + diff --git a/.import/rustgodottest.icon.png-d56bcdfb783f4fb63ef0fbffd631b690.stex b/.import/rustgodottest.icon.png-d56bcdfb783f4fb63ef0fbffd631b690.stex new file mode 100644 index 0000000..71f6913 Binary files /dev/null and b/.import/rustgodottest.icon.png-d56bcdfb783f4fb63ef0fbffd631b690.stex differ diff --git a/.import/rustgodottest.png-3a0452a0c796f6e85991767fc67eb07c.md5 b/.import/rustgodottest.png-3a0452a0c796f6e85991767fc67eb07c.md5 new file mode 100644 index 0000000..087b6ed --- /dev/null +++ b/.import/rustgodottest.png-3a0452a0c796f6e85991767fc67eb07c.md5 @@ -0,0 +1,3 @@ +source_md5="7e41bf3051b18e392a4bb6c0cc45cd7c" +dest_md5="73e4f4d3969b9486e63fd804f5f0f1a9" + diff --git a/.import/rustgodottest.png-3a0452a0c796f6e85991767fc67eb07c.stex b/.import/rustgodottest.png-3a0452a0c796f6e85991767fc67eb07c.stex new file mode 100644 index 0000000..3cf702c Binary files /dev/null and b/.import/rustgodottest.png-3a0452a0c796f6e85991767fc67eb07c.stex differ diff --git a/NativeTest.gdns b/NativeTest.gdns new file mode 100644 index 0000000..b0f5d57 --- /dev/null +++ b/NativeTest.gdns @@ -0,0 +1,11 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[sub_resource type="GDNativeLibrary" id=1] +entry/HTML5.wasm32 = "res://nativetest/target/wasm32-unknown-emscripten/release/nativetest.wasm" +entry/X11.64 = "res://nativetest/target/release/libnativetest.so" +dependency/HTML5.wasm32 = [ ] +dependency/X11.64 = [ ] + +[resource] +class_name = "HelloWorld" +library = SubResource( 1 ) diff --git a/Node2D.tscn b/Node2D.tscn new file mode 100644 index 0000000..9588664 --- /dev/null +++ b/Node2D.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://NativeTest.gdns" type="Script" id=1] + +[node name="Node2D" type="Node2D"] +script = ExtResource( 1 ) diff --git a/default_env.tres b/default_env.tres new file mode 100644 index 0000000..20207a4 --- /dev/null +++ b/default_env.tres @@ -0,0 +1,7 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +[resource] +background_mode = 2 +background_sky = SubResource( 1 ) diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..668ff5c --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,34 @@ +[preset.0] + +name="HTML5" +platform="HTML5" +runnable=true +custom_features="" +export_filter="all_resources" +include_filter="*.wasm" +exclude_filter="" +export_path="test/rustgodottest.html" +script_export_mode=1 +script_encryption_key="" + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +variant/export_type=2 +vram_texture_compression/for_desktop=true +vram_texture_compression/for_mobile=false +html/export_icon=true +html/custom_html_shell="res://template.html" +html/head_include="" +html/canvas_resize_policy=2 +html/focus_canvas_on_start=true +html/experimental_virtual_keyboard=false +progressive_web_app/enabled=false +progressive_web_app/offline_page="" +progressive_web_app/display=1 +progressive_web_app/orientation=0 +progressive_web_app/icon_144x144="" +progressive_web_app/icon_180x180="" +progressive_web_app/icon_512x512="" +progressive_web_app/background_color=Color( 0, 0, 0, 1 ) diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..c98fbb6 Binary files /dev/null and b/icon.png differ diff --git a/icon.png.import b/icon.png.import new file mode 100644 index 0000000..a4c02e6 --- /dev/null +++ b/icon.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/nativetest/.cargo/config.toml b/nativetest/.cargo/config.toml new file mode 100644 index 0000000..3632a76 --- /dev/null +++ b/nativetest/.cargo/config.toml @@ -0,0 +1,6 @@ +[target.wasm32-unknown-emscripten] +rustflags = [ + "-Clink-arg=-sSIDE_MODULE=2", # build a side module that Godot can load + "-Zlink-native-libraries=no", # workaround for a wasm-ld error during linking + "-Cpanic=abort", # workaround for a runtime error related to dyncalls +] diff --git a/nativetest/.envrc b/nativetest/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/nativetest/.envrc @@ -0,0 +1 @@ +use flake diff --git a/nativetest/.gitignore b/nativetest/.gitignore new file mode 100644 index 0000000..afecdba --- /dev/null +++ b/nativetest/.gitignore @@ -0,0 +1,3 @@ +/target +/Cargo.lock +.direnv \ No newline at end of file diff --git a/nativetest/Cargo.toml b/nativetest/Cargo.toml new file mode 100644 index 0000000..08690f0 --- /dev/null +++ b/nativetest/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "nativetest" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +gdnative = "0.11.2" \ No newline at end of file diff --git a/nativetest/flake.lock b/nativetest/flake.lock new file mode 100644 index 0000000..53ea172 --- /dev/null +++ b/nativetest/flake.lock @@ -0,0 +1,94 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1656363765, + "narHash": "sha256-al9eMT2a66tiQQMys40orUS7f2Wg9cBqbEd321HE/EA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ff8b619cfecb98bb94ae49ca7ceca937923a75fa", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ff8b619cfecb98bb94ae49ca7ceca937923a75fa", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1665296151, + "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1672712534, + "narHash": "sha256-8S0DdMPcbITnlOu0uA81mTo3hgX84wK8S9wS34HEFY4=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "69fb7bf0a8c40e6c4c197fa1816773774c8ac59f", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nativetest/flake.nix b/nativetest/flake.nix new file mode 100644 index 0000000..c6fc544 --- /dev/null +++ b/nativetest/flake.nix @@ -0,0 +1,29 @@ +{ + inputs = { + nixpkgs.url = + "github:NixOS/nixpkgs/ff8b619cfecb98bb94ae49ca7ceca937923a75fa"; + rust-overlay.url = "github:oxalica/rust-overlay"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; + in with pkgs; { + devShells.default = mkShell { + buildInputs = [ + (rust-bin.nightly."2022-09-02".default.override { + extensions = [ "rust-src" ]; + targets = [ "wasm32-unknown-emscripten" ]; + }) + libclang + emscripten + ]; + C_INCLUDE_PATH = "${emscripten}/share/emscripten/cache/sysroot/include"; + LIBCLANG_PATH = "${libclang.lib}/lib"; + EM_CACHE = "/tmp/emscripten-cache"; + }; + }); +} diff --git a/nativetest/src/lib.rs b/nativetest/src/lib.rs new file mode 100644 index 0000000..057a8f9 --- /dev/null +++ b/nativetest/src/lib.rs @@ -0,0 +1,23 @@ +use gdnative::prelude::*; + +#[derive(NativeClass)] +#[inherit(Node)] +struct HelloWorld; + +#[methods] +impl HelloWorld { + fn new(_owner: &Node) -> Self { + HelloWorld + } + + #[method] + fn _ready(&self) { + godot_print!("Hello from Rust!") + } +} + +fn init(handle: InitHandle) { + handle.add_class::(); +} + +godot_init!(init); \ No newline at end of file diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..d8a4e9f --- /dev/null +++ b/project.godot @@ -0,0 +1,27 @@ +; 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=4 + +[application] + +config/name="rustgodottest" +run/main_scene="res://Node2D.tscn" +config/icon="res://icon.png" + +[gui] + +common/drop_mouse_on_gui_input_disabled=true + +[physics] + +common/enable_pause_aware_picking=true + +[rendering] + +environment/default_environment="res://default_env.tres" diff --git a/template.html b/template.html new file mode 100644 index 0000000..0d385b5 --- /dev/null +++ b/template.html @@ -0,0 +1,25 @@ + + + + Titled Jam Team (internal build) + + + + + + + + +