| 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 | VkPipelineLayout pipelineLayout; |
| 93 | |
| 94 | void initWindow() { |
| 95 | glfwInit(); |
| 96 | |
| 97 | glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); |
| 98 | glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); |
| 99 | |
| 100 | window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr); |
| 101 | } |
| 102 | |
| 103 | void initVulkan() { |
| 104 | createInstance(); |
| 105 | setupDebugMessenger(); |
| 106 | createSurface(); |
| 107 | pickPhysicalDevice(); |
| 108 | createLogicalDevice(); |
| 109 | createSwapChain(); |
| 110 | createImageViews(); |
| 111 | createGraphicsPipeline(); |
| 112 | } |
| 113 | |
| 114 | void mainLoop() { |
| 115 | while (!glfwWindowShouldClose(window)) { |
| 116 | glfwPollEvents(); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | void cleanup() { |
| 121 | vkDestroyPipelineLayout(device, pipelineLayout, nullptr); |
nothing calls this directly
no outgoing calls
no test coverage detected