https://github.com/jspanchu/vtkdearimguiinjector
Inject DearImGUI into an existing VTK application. 💉
https://github.com/jspanchu/vtkdearimguiinjector
cmake cpp dear-imgui emscripten gles3 imgui sdl2 vtk vtk-applications vtk-library wasm webgl
Last synced: 6 months ago
JSON representation
Inject DearImGUI into an existing VTK application. 💉
- Host: GitHub
- URL: https://github.com/jspanchu/vtkdearimguiinjector
- Owner: jspanchu
- License: mit
- Created: 2021-05-27T11:30:12.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T15:51:33.000Z (almost 2 years ago)
- Last Synced: 2025-04-12T14:24:30.080Z (6 months ago)
- Topics: cmake, cpp, dear-imgui, emscripten, gles3, imgui, sdl2, vtk, vtk-applications, vtk-library, wasm, webgl
- Language: C++
- Homepage: https://jspanchu.dev/vtkDearImGUIInjector/
- Size: 52.3 MB
- Stars: 25
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vtkDearImGUIInjector
[](https://github.com/jspanchu/vtkDearImGUIInjector/actions/workflows/build-wasm.yml)Inject [DearImGUI](https://github.com/ocornut/imgui) into an existing VTK application.

# Build
## Desktop
Build the sample program by configuring the project with CMake. This step assumes you've built VTK.
```bash
cmake -GNinja -S . -B out -DVTK_DIR=/path/to/vtk/install/lib/cmake/vtk
cmake --build out
```Now you can run `./out/sample/main`.
## WebAssembly (for browsers)
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](https://jspanchu.dev/vtkDearImGUIInjector) web demo.```bash
npm run build-wasm
```# Serve web page
```bash
python3 -m http.server -d build-emscripten/sample 8080
# Open browser and visit http://localhost:8080
```# Notes
A very closely related project is phcerdan's https://github.com/phcerdan/vtkImGuiAdapter.
The two are slightly different in that:
1. With vtkDearImGUIInjector,
a. you do not have to take care of ImGUI contexts yourself.
b. no need to write an event loop.
2. 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.