Rust bindings for LiquidFun.
First, add the following to your Cargo.toml
:
toml
[dependencies]
liquidfun = "*"
Next, add this to your crate root:
rust
extern crate liquidfun;
```rust extern crate liquidfun;
use liquidfun::box2d::common::math::; use liquidfun::box2d::dynamics::world::;
fn hello_world() {
// Define the gravity vector.
let gravity = Vec2::new(0.0, -10.0);
// Construct a world object, which will hold and simulate the rigid bodies.
let mut world = World::new(&gravity);
assert_eq!(gravity, world.get_gravity());
}
```
The LiquidFun Hello World example compiles and runs. More bindings will be added as needed by projects that depend on LiquidFun Rust.
c_
prefix```cpp // C++ struct b2Vec2 { b2Vec2() {} ... float32 x, y; };
// new C struct typedef struct cb2Vec2 { float32 x, y; } cb2Vec2; ```
```cpp
cb2Vec2* cast(b2Vec2* v) {
return reinterpretcast
c_b2Vec2 sendStructFromCppToRustByValue() { b2Vec2 tmp; return *cast(&tmp); } ```
Erin Catto for Box2D
Google for LiquidFun
Nicolas Silva for box2d.rs