Inject DearImGUI into an existing VTK application.
Build the sample program by configuring the project with CMake. This step assumes you've built VTK.
cmake -GNinja -S . -B out -DVTK_DIR=/path/to/vtk/install/lib/cmake/vtk
cmake --build out
Now you can run ./out/sample/main
.
Compile the C++ sources against a pre-built VTK wasm docker image using npm and itk-wasm-cli. This is the very same method used for the live web demo.
npm run build-wasm
python3 -m http.server -d build-emscripten/sample 8080
# Open browser and visit http://localhost:8080
A very closely related project is phcerdan's https://github.com/phcerdan/vtkImGuiAdapter. The two are slightly different in that:
-
With vtkDearImGUIInjector,
a. you do not have to take care of ImGUI contexts yourself.
b. no need to write an event loop.
-
With vtkImGUIAdapter,
a. you are responsible for ensuring the sdl2 window is setup and the ImGUI context is initialized.
b. you must write an event loop in your application, ensure events are processed and ensure NewFrame/EndFrame are called.