GDNative Binding for Odin
Check out the demo for an example usage of this binding.
This binding is roughly 1-to-1 with the C API, but all godot_xx_ function prefixes have been removed. There are also some helper methods in gdnative_helper.odin.
The binding is very much a work in progress! There are bound to be missing features and bugs. Feel free to post an issue if you're having problems with the binding.
Export your init and terminate functions as c procs:
import gd "shared:gdnative-odin"
@(export)
godot_gdnative_init :: proc "c" (options: ^gd.GdnativeInitOptions) {
}
@(export)
godot_gdnative_terminate :: proc "c" (options: ^gd.GdnativeInitOptions) {
}Initializing the binding will map all loaded godot extensions to accessible fields:
godot_gdnative_init :: proc "c" (options: ^gd.GdnativeInitOptions) {
gd.init_api(options)
}
// later...
gd.ns_api.register_class(handle, "MyClass", "Node", create, destroy)Finally, make sure to terminate:
godot_gdnative_terminate :: proc "c" (options: ^gd.GdnativeInitOptions) {
gd.terminate_api(options)
}This is a bug with Odin's codegen and sadly wont be fixed until Odin's codegen on linux is fixed.