From 0c3b4b10bceb174a5eada976f75a57bc17447e0a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 10 Nov 2025 17:03:32 -0500 Subject: [PATCH] xo-imgui: refactor: MinimalImguiVulkan.instance -> instance_ --- xo-imgui/example/ex4a/imgui_ex4a.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/xo-imgui/example/ex4a/imgui_ex4a.cpp b/xo-imgui/example/ex4a/imgui_ex4a.cpp index d852fa75..40bb1f96 100644 --- a/xo-imgui/example/ex4a/imgui_ex4a.cpp +++ b/xo-imgui/example/ex4a/imgui_ex4a.cpp @@ -4375,7 +4375,7 @@ private: createInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR; #endif - int result = vkCreateInstance(&createInfo, nullptr, &instance); + int result = vkCreateInstance(&createInfo, nullptr, &(this->instance_)); if (result != VK_SUCCESS) { printf("vkCreateInstance failed with error: %d\n", result); throw std::runtime_error("Failed to create instance!"); @@ -4383,21 +4383,21 @@ private: } void createSurface() { - if (!SDL_Vulkan_CreateSurface(window_, instance, &surface)) { + if (!SDL_Vulkan_CreateSurface(window_, instance_, &surface)) { throw std::runtime_error("Failed to create SDL Vulkan surface!"); } } void pickPhysicalDevice() { uint32_t deviceCount = 0; - vkEnumeratePhysicalDevices(instance, &deviceCount, nullptr); + vkEnumeratePhysicalDevices(instance_, &deviceCount, nullptr); if (deviceCount == 0) { throw std::runtime_error("Failed to find GPUs with Vulkan support!"); } std::vector devices(deviceCount); - vkEnumeratePhysicalDevices(instance, &deviceCount, devices.data()); + vkEnumeratePhysicalDevices(instance_, &deviceCount, devices.data()); physicalDevice = devices[0]; // Just pick the first one for simplicity @@ -4664,7 +4664,7 @@ private: // Setup Platform/Renderer backends ImGui_ImplSDL2_InitForVulkan(window_); ImGui_ImplVulkan_InitInfo init_info = {}; - init_info.Instance = instance; + init_info.Instance = instance_; init_info.PhysicalDevice = physicalDevice; init_info.Device = device; init_info.QueueFamily = graphicsQueueFamily; @@ -4931,8 +4931,9 @@ private: vkDestroyRenderPass(device, renderPass, nullptr); vkDestroyDescriptorPool(device, descriptorPool, nullptr); vkDestroyDevice(device, nullptr); - vkDestroySurfaceKHR(instance, surface, nullptr); - vkDestroyInstance(instance, nullptr); + vkDestroySurfaceKHR(instance_, surface, nullptr); + vkDestroyInstance(instance_, nullptr); + this->instance_ = nullptr; SDL_DestroyWindow(window_); this->window_ = nullptr; @@ -4943,7 +4944,7 @@ private: private: SDL_Window* window_ = nullptr; - VkInstance instance; + VkInstance instance_; VkPhysicalDevice physicalDevice; VkDevice device; VkQueue graphicsQueue;