| 108 | }; |
| 109 | |
| 110 | class HelloTriangleApplication { |
| 111 | public: |
| 112 | void run() { |
| 113 | initWindow(); |
| 114 | initVulkan(); |
| 115 | mainLoop(); |
| 116 | cleanup(); |
| 117 | } |
| 118 | |
| 119 | private: |
| 120 | GLFWwindow* window; |
| 121 | |
| 122 | VkInstance instance; |
| 123 | VkDebugUtilsMessengerEXT debugMessenger; |
| 124 | VkSurfaceKHR surface; |
| 125 | |
| 126 | VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; |
| 127 | VkDevice device; |
| 128 | |
| 129 | VkQueue graphicsQueue; |
| 130 | VkQueue presentQueue; |
| 131 | |
| 132 | VkSwapchainKHR swapChain; |
| 133 | std::vector<VkImage> swapChainImages; |
| 134 | VkFormat swapChainImageFormat; |
| 135 | VkExtent2D swapChainExtent; |
| 136 | std::vector<VkImageView> swapChainImageViews; |
| 137 | std::vector<VkFramebuffer> swapChainFramebuffers; |
| 138 | |
| 139 | VkRenderPass renderPass; |
| 140 | VkPipelineLayout pipelineLayout; |
| 141 | VkPipeline graphicsPipeline; |
| 142 | |
| 143 | VkCommandPool commandPool; |
| 144 | |
| 145 | VkBuffer vertexBuffer; |
| 146 | VkDeviceMemory vertexBufferMemory; |
| 147 | VkBuffer indexBuffer; |
| 148 | VkDeviceMemory indexBufferMemory; |
| 149 | |
| 150 | std::vector<VkCommandBuffer> commandBuffers; |
| 151 | |
| 152 | std::vector<VkSemaphore> imageAvailableSemaphores; |
| 153 | std::vector<VkSemaphore> renderFinishedSemaphores; |
| 154 | std::vector<VkFence> inFlightFences; |
| 155 | uint32_t currentFrame = 0; |
| 156 | |
| 157 | bool framebufferResized = false; |
| 158 | |
| 159 | void initWindow() { |
| 160 | glfwInit(); |
| 161 | |
| 162 | glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); |
| 163 | |
| 164 | window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr); |
| 165 | glfwSetWindowUserPointer(window, this); |
| 166 | glfwSetFramebufferSizeCallback(window, framebufferResizeCallback); |
| 167 | } |
nothing calls this directly
no outgoing calls
no test coverage detected