I occasionally need/want to write a small 3D program with a bit of UI (e.g. qt-tracing, hyperboloid). So this is what I came up with:

Basically, it integrates WGPU-based rendering with Qt UI to take the best of each. It requires X11 but that should be fixable. (It also requires Qt 6 and KDE Frameworks 6, but downgrading to just Qt 5 should be trivial).

The build system is cmake calling cargo (because cargo feels a lot easier to call from something else). The Rust side is built as a normal library crate and a dependent staticlib crate. The C++ side is a normal executable linking to that staticlib. It’s also possible to just cargo run but it won’t build the UI, using a plain winit window instead.

Internally, the interop is hand-written as it’s just a handful of functions. I’ve thought of automating it but so far, I’ve only worked with cbindgen and it only really helps with structs, not with methods. Besides, integrating it into the build is non-trivial as well (I tried and while I got it working with cargo install --root ..., it’s not exactly a solution I like).

1 post - 1 participant

Read full topic