xo-imgui: support dynamic vsync_enabled setting + demo in ex4

This commit is contained in:
Roland Conybeare 2025-11-12 13:33:20 -05:00
commit b4a8ecd7d6
5 changed files with 58 additions and 14 deletions

View file

@ -80,7 +80,7 @@ namespace {
*p_f = 0.0f;
*p_counter = 0;
return [p_app_state, p_draw_state, p_f, p_counter](ImGuiContext * imgui_cx)
return [p_app_state, p_draw_state, p_f, p_counter](VulkanApp * vulkan_app, ImGuiContext * imgui_cx)
{
scope log(XO_DEBUG(false));
@ -108,6 +108,19 @@ namespace {
ImGui::End();
# endif
// 0. main menubar
if (ImGui::BeginMainMenuBar()) {
if (ImGui::BeginMenu("View")) {
bool x = vulkan_app->vsync_enabled_flag();
if (ImGui::MenuItem("vsync", nullptr, &x)) {
vulkan_app->update_vsync_enabled(x);
}
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
// 1. create a simple ImGui window
ImGui::Begin("Hello, Vulkan + SDL2!");
ImGui::Text("This is a minimal ImGui + Vulkan + SDL2 example!");