summaryrefslogtreecommitdiff
path: root/klangfarbrs/src
diff options
context:
space:
mode:
authorJacob Lee <jacob.nmi.lee@gmail.com>2021-10-16 22:04:31 -0400
committerGitHub <noreply@github.com>2021-10-16 22:04:31 -0400
commita0ef84b0474219bedf603a293a2ee8d4fab32ec0 (patch)
treeaf0d1a80d630470ce70a817503b39d3bbcd0dbd4 /klangfarbrs/src
parent9d78a9f5ebd931593b2644dff57cb1d2238876d3 (diff)
Add Godot and Rust files
Diffstat (limited to 'klangfarbrs/src')
-rw-r--r--klangfarbrs/src/lib.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/klangfarbrs/src/lib.rs b/klangfarbrs/src/lib.rs
new file mode 100644
index 0000000..4843910
--- /dev/null
+++ b/klangfarbrs/src/lib.rs
@@ -0,0 +1,29 @@
+use gdnative::prelude::*;
+
+/// The HelloWorld "class"
+#[derive(NativeClass)]
+#[inherit(Node)]
+pub struct HelloWorld;
+
+#[methods]
+impl HelloWorld {
+ fn new(_owner: &Node) -> Self {
+ HelloWorld
+ }
+
+ #[export]
+ fn _ready(&self, _owner: &Node) {
+ // The `godot_print!` macro works like `println!` but prints to the Godot-editor
+ // output tab as well.
+ godot_print!("Hello, world!");
+ }
+}
+
+// Function that registers all exposed classes to Godot
+fn init(handle: InitHandle) {
+ // Register the new `HelloWorld` type we just declared.
+ handle.add_class::<HelloWorld>();
+}
+
+// Macro that creates the entry-points of the dynamic library.
+godot_init!(init);