| 62 | }; |
| 63 | |
| 64 | class HelloTriangleApplication { |
| 65 | public: |
| 66 | void run() { |
| 67 | initWindow(); |
| 68 | initVulkan(); |
| 69 | mainLoop(); |
| 70 | cleanup(); |
| 71 | } |
| 72 | |
| 73 | private: |
| 74 | GLFWwindow* window; |
| 75 | |
| 76 | VkInstance instance; |
| 77 | VkDebugUtilsMessengerEXT debugMessenger; |
| 78 | VkSurfaceKHR surface; |
| 79 | |
| 80 | VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; |
| 81 | VkDevice device; |
| 82 | |
| 83 | VkQueue graphicsQueue; |
| 84 | VkQueue presentQueue; |
| 85 | |
| 86 | VkSwapchainKHR swapChain; |
| 87 | std::vector<VkImage> swapChainImages; |
| 88 | VkFormat swapChainImageFormat; |
| 89 | VkExtent2D swapChainExtent; |
| 90 | std::vector<VkImageView> swapChainImageViews; |
| 91 | |
| 92 | void initWindow() { |
| 93 | glfwInit(); |
| 94 | |
| 95 | glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); |
| 96 | glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); |
| 97 | |
| 98 | window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr); |
| 99 | } |
| 100 | |
| 101 | void initVulkan() { |
| 102 | createInstance(); |
| 103 | setupDebugMessenger(); |
| 104 | createSurface(); |
| 105 | pickPhysicalDevice(); |
| 106 | createLogicalDevice(); |
| 107 | createSwapChain(); |
| 108 | createImageViews(); |
| 109 | createGraphicsPipeline(); |
| 110 | } |
| 111 | |
| 112 | void mainLoop() { |
| 113 | while (!glfwWindowShouldClose(window)) { |
| 114 | glfwPollEvents(); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | void cleanup() { |
| 119 | for (auto imageView : swapChainImageViews) { |
| 120 | vkDestroyImageView(device, imageView, nullptr); |
| 121 | } |
nothing calls this directly
no outgoing calls
no test coverage detected