Changeset 80de39d in opengl-game
- Timestamp:
- Jul 8, 2019, 6:08:50 PM (6 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 909b51a
- Parents:
- a8f0577
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
ra8f0577 r80de39d 58 58 } 59 59 60 void DestroyDebugUtilsMessengerEXT(VkInstance instance, 61 VkDebugUtilsMessengerEXT debugMessenger, 62 const VkAllocationCallbacks* pAllocator) { 63 auto func = (PFN_vkDestroyDebugUtilsMessengerEXT) vkGetInstanceProcAddr( 64 instance, "vkDestroyDebugUtilsMessengerEXT"); 65 66 if (func != nullptr) { 67 func(instance, debugMessenger, pAllocator); 68 } 69 } 70 60 71 class VulkanGame { 61 72 public: … … 70 81 private: 71 82 GameGui_SDL gui; 72 SDL_Window* window = NULL;83 SDL_Window* window = nullptr; 73 84 74 85 VkInstance instance; … … 90 101 SDL_WINDOW_VULKAN | SDL_WINDOW_SHOWN); 91 102 92 if (window == NULL) {103 if (window == nullptr) { 93 104 cout << "Window could not be created!" << endl; 94 105 return RTWO_ERROR; … … 125 136 createInfo.ppEnabledExtensionNames = extensions.data(); 126 137 138 VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo; 127 139 if (enableValidationLayers) { 128 140 createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size()); 129 141 createInfo.ppEnabledLayerNames = validationLayers.data(); 142 143 populateDebugMessengerCreateInfo(debugCreateInfo); 144 createInfo.pNext = &debugCreateInfo; 130 145 } else { 131 146 createInfo.enabledLayerCount = 0; 147 148 createInfo.pNext = nullptr; 132 149 } 133 150 … … 137 154 } 138 155 139 void setupDebugMessenger() { 140 if (!enableValidationLayers) return; 141 142 VkDebugUtilsMessengerCreateInfoEXT createInfo = {}; 156 void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo) { 157 createInfo = {}; 143 158 createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT; 144 159 createInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT; 145 160 createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT; 146 161 createInfo.pfnUserCallback = debugCallback; 147 createInfo.pUserData = nullptr; 162 } 163 164 void setupDebugMessenger() { 165 if (!enableValidationLayers) return; 166 167 VkDebugUtilsMessengerCreateInfoEXT createInfo; 168 populateDebugMessengerCreateInfo(createInfo); 148 169 149 170 if (CreateDebugUtilsMessengerEXT(instance, &createInfo, nullptr, &debugMessenger) != VK_SUCCESS) { … … 231 252 232 253 void cleanup() { 254 if (enableValidationLayers) { 255 DestroyDebugUtilsMessengerEXT(instance, debugMessenger, nullptr); 256 } 257 233 258 vkDestroyInstance(instance, nullptr); 234 259
Note:
See TracChangeset
for help on using the changeset viewer.