Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions guide/src/dear_imgui/imgui_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ m_device->resetFences(*render_sync.drawn);
m_imgui->new_frame();

// ...
render_sync.command_buffer.beginRendering(rendering_info);
command_buffer.beginRendering(rendering_info);
ImGui::ShowDemoWindow();
// draw stuff here.
render_sync.command_buffer.endRendering();
command_buffer.endRendering();
```

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.
ImGui doesn't draw anything here (the actual draw command requires the Command Buffer), it's just a good customization point for all higher level logic.

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).

```cpp
m_imgui->end_frame();
rendering_info.setColorAttachments(attachment_info)
rendering_info.setColorAttachments(color_attachment)
.setPDepthAttachment(nullptr);
render_sync.command_buffer.beginRendering(rendering_info);
m_imgui->render(render_sync.command_buffer);
render_sync.command_buffer.endRendering();
command_buffer.beginRendering(rendering_info);
m_imgui->render(command_buffer);
command_buffer.endRendering();
```

![ImGui Demo](./imgui_demo.png)
9 changes: 9 additions & 0 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ auto App::wait_for_frame() -> vk::CommandBuffer {
// reset fence _after_ acquisition of image: if it fails, the
// fence remains signaled.
m_device->resetFences(*render_sync.drawn);
m_imgui->new_frame();

auto command_buffer_bi = vk::CommandBufferBeginInfo{};
// this flag means recorded commands will not be reused.
Expand Down Expand Up @@ -238,8 +239,16 @@ void App::render(vk::CommandBuffer const command_buffer) {
.setLayerCount(1);

command_buffer.beginRendering(rendering_info);
ImGui::ShowDemoWindow();
// draw stuff here.
command_buffer.endRendering();

m_imgui->end_frame();
rendering_info.setColorAttachments(color_attachment)
.setPDepthAttachment(nullptr);
command_buffer.beginRendering(rendering_info);
m_imgui->render(command_buffer);
command_buffer.endRendering();
}

void App::transition_for_present(vk::CommandBuffer const command_buffer) const {
Expand Down