-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experiment with imgui-rs for the UI #438
Comments
Imgui turned out to be more complicated to compile than I thought. The following works:
(off-topic: it is quite frustrating to not be able to put these C++ flags in some configuration file and instead having to pass them every single time) Unfortunately I'm getting linking errors about function signature mismatches between the Rust bindings and the actual implementations. It seems that Rust thinks that |
It seems that the bindings in the imgui crate are wrong-ish. When I do the following: diff --git a/imgui-sys-bindgen/src/lib.rs b/imgui-sys-bindgen/src/lib.rs
index 7f74258..4033e72 100644
--- a/imgui-sys-bindgen/src/lib.rs
+++ b/imgui-sys-bindgen/src/lib.rs
@@ -89,6 +89,8 @@ pub fn generate_bindings<P: AsRef<Path>>(cimgui_path: &P) -> Result<Bindings, Er
.raw_line("#![allow(non_camel_case_types)]")
.raw_line("#![allow(non_snake_case)]")
.raw_line("#![allow(clippy::all)]")
+ .clang_arg("--target=wasm32-wasi")
+ .clang_arg("--sysroot=/home/pierre/Projets/wasi-sdk-10.0/share/wasi-sysroot")
.header_contents("cimgui.h", &header)
.rust_target(RustTarget::Stable_1_36)
.default_enum_style(EnumVariation::Consts) Then the sizes of all structs are different. Also some structs are missing (?!?!) and all the exports are missing from the bindings too. Issues with C/C++ compilers are tiring. |
The following diff leads to bindings being generated: diff --git a/imgui-sys-bindgen/src/lib.rs b/imgui-sys-bindgen/src/lib.rs
index 7f74258..68e727f 100644
--- a/imgui-sys-bindgen/src/lib.rs
+++ b/imgui-sys-bindgen/src/lib.rs
@@ -89,6 +89,9 @@ pub fn generate_bindings<P: AsRef<Path>>(cimgui_path: &P) -> Result<Bindings, Er
.raw_line("#![allow(non_camel_case_types)]")
.raw_line("#![allow(non_snake_case)]")
.raw_line("#![allow(clippy::all)]")
+ .clang_arg("--target=wasm32-wasi")
+ .clang_arg("--sysroot=/home/pierre/Projets/wasi-sdk-10.0/share/wasi-sysroot")
+ .clang_arg("-fvisibility=default")
.header_contents("cimgui.h", &header)
.rust_target(RustTarget::Stable_1_36)
.default_enum_style(EnumVariation::Consts) Unfortunately I'm still getting linking errors. |
The linking errors were caused by rust-lang/rust#71871 Compiles with:
|
Need to pass |
cc #194
Getting any real UI framework to work on redshirt would require either support for hardware acceleration, or a software implementation of OpenGL or WebGPU. Both these solutions are quite inaccessible at the moment.
As a way to get started with a desktop environment, a possibility could be to use imgui-rs.
It should be easy (for a certain definition of "easy") to write a software renderer for imgui. I've also checked, and the C++ code of imgui compiles just fine for wasi provided you pass the Wasi libc with
CXXFLAGS_wasm32_wasi="--sysroot=/path/to/wasi-libc/sysroot" cargo b --target=wasm32-wasi
The text was updated successfully, but these errors were encountered: