summaryrefslogtreecommitdiff
path: root/klangfarbrs/src
diff options
context:
space:
mode:
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);