# vtk+DearImGui integration through vtkGenericOpenGLRenderWindow

**URL:** https://discourse.vtk.org/t/vtk-dearimgui-integration-through-vtkgenericopenglrenderwindow/4424
**Category:** Development
**Tags:** proposal
**Created:** [October 15, 2020, 6:14am UTC](https://discourse.vtk.org/t/vtk-dearimgui-integration-through-vtkgenericopenglrenderwindow/4424 "2020-10-15T06:14:03Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![phcerdan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/phcerdan/32/54_2.png) [@phcerdan](https://discourse.vtk.org/u/phcerdan)
#### Post date: [March 22, 2021, 4:03pm UTC](https://discourse.vtk.org/t/vtk-dearimgui-integration-through-vtkgenericopenglrenderwindow/4424/2 "2021-03-22T16:03:42Z")

</div>

Thanks for sharing @jaswantp!

I had a go on integrating vtk+ImGui: [GitHub - phcerdan/vtkImGuiAdapter: Adapter to add imgui to an existing vtkRenderWindow using SDL2.](https://github.com/phcerdan/vtkImGuiAdapter/)

vtkImGuiAdapter provides two classes: `vtkImGuiSDL2OpenGLRenderWindow` (subclass of the `vtkSDL2OpenGLRendeWindow` available since 9.0) and `vtkImGuiSDL2RenderWindowInteractor`.

vtkImGuiAdapter takes the path to override `Frame` and let ImGui loop control the re-rendering. The render window is owned by VTK, and ImGui writes on it. I am sure optimizations can be done by someone with more OpenGL knowledge than myself to avoid some unnecessary re-renderings.

It has worked for me pretty well to put up some demos really quick.

 ![vtkImguiAdapter_example](https://discourse.vtk.org/uploads/default/original/2X/e/ea5ed96a24b0855a60b423e6719ca0bb07fe6cda.gif)

Here is the [code example](https://github.com/phcerdan/vtkImGuiAdapter/blob/6552628028d4fddd36485e41ca787453f27e679c/example-imgui-vtk-sdl.cpp) that generates that gif.

[Link to the discourse post](https://discourse.vtk.org/t/interactive-text-widget-search-box/4009/5) where I first introduced it

---

_[View the full topic](https://discourse.vtk.org/t/vtk-dearimgui-integration-through-vtkgenericopenglrenderwindow/4424)._
