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

Class HelloTriangleApplication

code/06_swap_chain_creation.cpp:63–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected