Skip to content

Commit fe8bc91

Browse files
committed
Issue ImGui API calls inside app render pass
1 parent 3e59aa8 commit fe8bc91

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

guide/src/dear_imgui/imgui_integration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@ Start a new ImGui frame after resetting the render fence, and show the demo wind
3333
m_device->resetFences(*render_sync.drawn);
3434
m_imgui->new_frame();
3535

36+
// ...
37+
render_sync.command_buffer.beginRendering(rendering_info);
3638
ImGui::ShowDemoWindow();
39+
// draw stuff here.
40+
render_sync.command_buffer.endRendering();
3741
```
3842
43+
ImGui doesn't draw anything here (the actual draw command requires the Command Buffer), it's just a good customization point to use indirection at later.
44+
3945
We use a separate render pass for Dear ImGui, again for isolation, and to enable us to change the main render pass later, eg by adding a depth buffer attachment (`DearImGui` is setup assuming its render pass will only use a single color attachment).
4046
4147
```cpp

src/app.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ void App::main_loop() {
183183
m_device->resetFences(*render_sync.drawn);
184184
m_imgui->new_frame();
185185

186-
ImGui::ShowDemoWindow();
187-
188186
auto command_buffer_bi = vk::CommandBufferBeginInfo{};
189187
// this flag means recorded commands will not be reused.
190188
command_buffer_bi.setFlags(
@@ -222,6 +220,7 @@ void App::main_loop() {
222220
.setLayerCount(1);
223221

224222
render_sync.command_buffer.beginRendering(rendering_info);
223+
ImGui::ShowDemoWindow();
225224
// draw stuff here.
226225
render_sync.command_buffer.endRendering();
227226

0 commit comments

Comments
 (0)