MCPcopy Create free account
hub / github.com/Overv/VulkanTutorial / HelloTriangleApplication

Class HelloTriangleApplication

code/18_vertex_input.cpp:105–989  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected