diff --git a/guide/src/dear_imgui/imgui_integration.md b/guide/src/dear_imgui/imgui_integration.md index b52d402..56a4505 100644 --- a/guide/src/dear_imgui/imgui_integration.md +++ b/guide/src/dear_imgui/imgui_integration.md @@ -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) diff --git a/src/app.cpp b/src/app.cpp index 0a66bbc..7b2ae7e 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -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. @@ -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 {