I investigated the possibility to use sokol_app as a backend for imgui_manual. I'm not sure the next version will be using sokol, but this issue it here to summarize the status.
a backend for imgui (similarly to sokol_app.h, but limited to imgui)
an easy way to organize the app docking layout and its callbacks: this part is heavily used by imgui_manual.
a way to embed assets into the application being built (be it on iOS, Android, emscripten, windows, etc). This is also used by imgui_manual.
So the way I did it was to bypass completely the backend provided by hello_imgui, and instead create a sapp_desc from HelloImGui::RunnerParams: see hello_imgui_sokol.h and hello_imgui_sokol.cpp
With sokol, the wasm blob is twice smaller. However since there are lots of resources in the manual (see imgui_manual.data), the gain is not so obvious.
See below a comparison of the sizes in kilobytes:
➜ imgui_manual git:(sokol) ✗ find build_emscripten/src/ -name "imgui_manual.*" -type f |xargs du -ck
4 build_emscripten/src//imgui_manual.html
2112 build_emscripten/src//imgui_manual.wasm
3300 build_emscripten/src//imgui_manual.data
276 build_emscripten/src//imgui_manual.js
5692 total
➜ imgui_manual git:(sokol) ✗ find build_emscripten_sokol/src/ -name "imgui_manual.*" -type f |xargs du -ck
4 build_emscripten_sokol/src//imgui_manual.html
1088 build_emscripten_sokol/src//imgui_manual.wasm
3300 build_emscripten_sokol/src//imgui_manual.data
172 build_emscripten_sokol/src//imgui_manual.js
4564 total
Current limitations of the sokol emscripten version
At the moment, it cannot load additional fonts, so that the manual looks a bit broken (since lots of icons use font-awesome)
Also image loaded via OpenGL from the assets (see image_gl.cpp) are not displayed
I investigated the possibility to use sokol_app as a backend for imgui_manual. I'm not sure the next version will be using sokol, but this issue it here to summarize the status.
A demo of imgui_manual that uses sokol can be seen live here: https://pthom.github.io/imgui_manual_online/manual_sokol/imgui_manual.html?version=1
In order to use sokol, I had to do a few adaptations:
Inside hello_imgui:
Full diff here: https://github.com/pthom/hello_imgui/compare/sokol?expand=1
hello_imgui provides the following services:
So the way I did it was to bypass completely the backend provided by hello_imgui, and instead create a
sapp_desc
fromHelloImGui::RunnerParams
: see hello_imgui_sokol.h and hello_imgui_sokol.cppThis way a minimal app that uses sokol and hello_imgui would look like this: hello_imgui_demo_sokol.cpp
Inside imgui_manual:
Full diff here: https://github.com/pthom/imgui_manual/compare/sokol?expand=1
Once hello_imgui was adapted, the modifications were quite straightforward: the most important modification is in the main file, and it shows the difference when launching the manual via sokol_main instead of the usual main
Status:
Wasm blob and full page size:
With sokol, the wasm blob is twice smaller. However since there are lots of resources in the manual (see imgui_manual.data), the gain is not so obvious.
See below a comparison of the sizes in kilobytes:
Current limitations of the sokol emscripten version