@@ -433,11 +433,23 @@ int main(int, char**)
433
433
ImGuiIO& io = ImGui::GetIO (); (void )io;
434
434
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
435
435
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
436
+ io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
437
+ io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
438
+ // io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons;
439
+ // io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge;
436
440
437
441
// Setup Dear ImGui style
438
442
ImGui::StyleColorsDark ();
439
443
// ImGui::StyleColorsLight();
440
444
445
+ // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
446
+ ImGuiStyle& style = ImGui::GetStyle ();
447
+ if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
448
+ {
449
+ style.WindowRounding = 0 .0f ;
450
+ style.Colors [ImGuiCol_WindowBg].w = 1 .0f ;
451
+ }
452
+
441
453
// Setup Platform/Renderer backends
442
454
ImGui_ImplSDL3_InitForVulkan (window);
443
455
ImGui_ImplVulkan_InitInfo init_info = {};
@@ -557,17 +569,25 @@ int main(int, char**)
557
569
558
570
// Rendering
559
571
ImGui::Render ();
560
- ImDrawData* draw_data = ImGui::GetDrawData ();
561
- const bool is_minimized = (draw_data->DisplaySize .x <= 0 .0f || draw_data->DisplaySize .y <= 0 .0f );
562
- if (!is_minimized)
572
+ ImDrawData* main_draw_data = ImGui::GetDrawData ();
573
+ const bool main_is_minimized = (main_draw_data->DisplaySize .x <= 0 .0f || main_draw_data->DisplaySize .y <= 0 .0f );
574
+ wd->ClearValue .color .float32 [0 ] = clear_color.x * clear_color.w ;
575
+ wd->ClearValue .color .float32 [1 ] = clear_color.y * clear_color.w ;
576
+ wd->ClearValue .color .float32 [2 ] = clear_color.z * clear_color.w ;
577
+ wd->ClearValue .color .float32 [3 ] = clear_color.w ;
578
+ if (!main_is_minimized)
579
+ FrameRender (wd, main_draw_data);
580
+
581
+ // Update and Render additional Platform Windows
582
+ if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
563
583
{
564
- wd->ClearValue .color .float32 [0 ] = clear_color.x * clear_color.w ;
565
- wd->ClearValue .color .float32 [1 ] = clear_color.y * clear_color.w ;
566
- wd->ClearValue .color .float32 [2 ] = clear_color.z * clear_color.w ;
567
- wd->ClearValue .color .float32 [3 ] = clear_color.w ;
568
- FrameRender (wd, draw_data);
569
- FramePresent (wd);
584
+ ImGui::UpdatePlatformWindows ();
585
+ ImGui::RenderPlatformWindowsDefault ();
570
586
}
587
+
588
+ // Present Main Platform Window
589
+ if (!main_is_minimized)
590
+ FramePresent (wd);
571
591
}
572
592
573
593
// Cleanup
0 commit comments