6 releases

0.2.1 Dec 8, 2024
0.2.0 Nov 15, 2024
0.1.3 Jul 22, 2024
0.1.1 Jun 24, 2024
0.0.0 Nov 23, 2021

#2259 in Game dev

Download history 161/week @ 2024-08-31 124/week @ 2024-09-07 138/week @ 2024-09-14 192/week @ 2024-09-21 189/week @ 2024-09-28 113/week @ 2024-10-05 204/week @ 2024-10-12 421/week @ 2024-10-19 127/week @ 2024-10-26 209/week @ 2024-11-02 286/week @ 2024-11-09 364/week @ 2024-11-16 467/week @ 2024-11-23 282/week @ 2024-11-30 504/week @ 2024-12-07 386/week @ 2024-12-14

1,660 downloads per month
Used in 8 crates (via godot-core)

MPL-2.0 license

165KB
2.5K SLoC

logo.png

Rust bindings for Godot 4

Website | Book | API Docs | Discord | Mastodon | Twitter | Sponsor

gdext is a library to integrate the Rust language with Godot 4.

Godot is an open-source game engine, focusing on a productive and batteries-included 2D and 3D experience.
Its GDExtension API allows integrating third-party languages and libraries.

Rust bindings for Godot 3 (GDNative API) are available in gdnative.

Philosophy

The Rust binding is an alternative to GDScript, with a focus on type safety, scalability and performance.

The primary goal of gdext is to provide a pragmatic Rust API for game developers.

Recurring workflows should be simple and require minimal boilerplate. APIs are designed to be safe and idiomatic Rust wherever possible. Due to interacting with Godot as a C++ engine, we sometimes follow unconventional approaches to provide a good user experience.

Development status

The gdext library has evolved a lot during 2023 and 2024 and is now in a usable state for smaller projects. However, there are still certain things to keep in mind.

[!WARNING]
The public API introduces breaking changes from time to time, primarily motivated by new features and improved ergonomics. Our crates.io releases adhere to SemVer, but may lag behind the master branch. See also API stability in the book.

Features: Most Godot APIs have been mapped at this point. The current focus lies on a more natural Rust experience and enable more design patterns that come in handy for day-to-day game development. See #24 for an up-to-date feature overview.

At the moment, there is experimental support for Wasm, Android and iOS, but documentation and tooling is still lacking. Contributions are very welcome!

Bugs: Most undefined behavior related to the FFI layer has been ironed out, but there may still be occasional safety issues. Apart from that, new additions to the library are typically not feature-complete from the start, but become more robust with feedback and testing over time. To counter bugs, we have an elaborate CI suite including clippy, unit tests, engine integration tests and memory sanitizers. Even hot-reload is tested!

Getting started

To dive into Rust development with gdext, check out the godot-rust book. The book is still under construction, but already covers a Hello World setup as well as several more in-depth chapters.

To consult the API reference, have a look at the online API Docs.

Furthermore, we provide a small example game in the examples/dodge-the-creeps directory.
The example examples/hot-reload demonstrates hot-reloading in the Godot editor.

If you need help, join our Discord server and ask in the #help channel!

License

We use the Mozilla Public License 2.0. MPL tries to find a balance between permissive (MIT, Apache, Zlib) and copyleft licenses (GPL, LGPL).

The license provides a lot of freedom: you can use the library commercially and keep your own code closed-source, i.e. game development is not restricted. The main condition is that if you change gdext itself, you need to make those changes available (and only those, no surrounding code).

Contributing

Contributions are very welcome! If you want to help out, see Contributing.md for some pointers on getting started.


lib.rs:

Internal crate of godot-rust

Do not depend on this crate directly, instead use the godot crate. No SemVer or other guarantees are provided.

Contributor docs

Low level bindings to the provided C core API.

Dependencies

~0–1.8MB
~24K SLoC