| 64 | }; |
| 65 | |
| 66 | class HelloTriangleApplication { |
| 67 | public: |
| 68 | void run() { |
| 69 | initWindow(); |
| 70 | initVulkan(); |
| 71 | mainLoop(); |
| 72 | cleanup(); |
| 73 | } |
| 74 | |
| 75 | private: |
| 76 | GLFWwindow* window; |
| 77 | |
| 78 | VkInstance instance; |
| 79 | VkDebugUtilsMessengerEXT debugMessenger; |
| 80 | VkSurfaceKHR surface; |
| 81 | |
| 82 | VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; |
| 83 | VkDevice device; |
| 84 | |
| 85 | VkQueue graphicsQueue; |
| 86 | VkQueue presentQueue; |
| 87 | |
| 88 | VkSwapchainKHR swapChain; |
| 89 | std::vector<VkImage> swapChainImages; |
| 90 | VkFormat swapChainImageFormat; |
| 91 | VkExtent2D swapChainExtent; |
| 92 | std::vector<VkImageView> swapChainImageViews; |
| 93 | std::vector<VkFramebuffer> swapChainFramebuffers; |
| 94 | |
| 95 | VkRenderPass renderPass; |
| 96 | VkPipelineLayout pipelineLayout; |
| 97 | VkPipeline graphicsPipeline; |
| 98 | |
| 99 | VkCommandPool commandPool; |
| 100 | std::vector<VkCommandBuffer> commandBuffers; |
| 101 | |
| 102 | std::vector<VkSemaphore> imageAvailableSemaphores; |
| 103 | std::vector<VkSemaphore> renderFinishedSemaphores; |
| 104 | std::vector<VkFence> inFlightFences; |
| 105 | uint32_t currentFrame = 0; |
| 106 | |
| 107 | bool framebufferResized = false; |
| 108 | |
| 109 | void initWindow() { |
| 110 | glfwInit(); |
| 111 | |
| 112 | glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); |
| 113 | |
| 114 | window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr); |
| 115 | glfwSetWindowUserPointer(window, this); |
| 116 | glfwSetFramebufferSizeCallback(window, framebufferResizeCallback); |
| 117 | } |
| 118 | |
| 119 | static void framebufferResizeCallback(GLFWwindow* window, int width, int height) { |
| 120 | auto app = reinterpret_cast<HelloTriangleApplication*>(glfwGetWindowUserPointer(window)); |
| 121 | app->framebufferResized = true; |
| 122 | } |
| 123 |
nothing calls this directly
no outgoing calls
no test coverage detected