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

Class HelloTriangleApplication

code/08_graphics_pipeline.cpp:63–519  ·  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 std::vector<VkImageView> swapChainImageViews;
90
91 void initWindow() {
92 glfwInit();
93
94 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
95 glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
96
97 window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr);
98 }
99
100 void initVulkan() {
101 createInstance();
102 setupDebugMessenger();
103 createSurface();
104 pickPhysicalDevice();
105 createLogicalDevice();
106 createSwapChain();
107 createImageViews();
108 createGraphicsPipeline();
109 }
110
111 void mainLoop() {
112 while (!glfwWindowShouldClose(window)) {
113 glfwPollEvents();
114 }
115 }
116
117 void cleanup() {
118 for (auto imageView : swapChainImageViews) {
119 vkDestroyImageView(device, imageView, nullptr);
120 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected