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

Class HelloTriangleApplication

code/04_logical_device.cpp:48–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46};
47
48class HelloTriangleApplication {
49public:
50 void run() {
51 initWindow();
52 initVulkan();
53 mainLoop();
54 cleanup();
55 }
56
57private:
58 GLFWwindow* window;
59
60 VkInstance instance;
61 VkDebugUtilsMessengerEXT debugMessenger;
62
63 VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
64 VkDevice device;
65
66 VkQueue graphicsQueue;
67
68 void initWindow() {
69 glfwInit();
70
71 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
72 glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
73
74 window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr);
75 }
76
77 void initVulkan() {
78 createInstance();
79 setupDebugMessenger();
80 pickPhysicalDevice();
81 createLogicalDevice();
82 }
83
84 void mainLoop() {
85 while (!glfwWindowShouldClose(window)) {
86 glfwPollEvents();
87 }
88 }
89
90 void cleanup() {
91 vkDestroyDevice(device, nullptr);
92
93 if (enableValidationLayers) {
94 DestroyDebugUtilsMessengerEXT(instance, debugMessenger, nullptr);
95 }
96
97 vkDestroyInstance(instance, nullptr);
98
99 glfwDestroyWindow(window);
100
101 glfwTerminate();
102 }
103
104 void createInstance() {
105 if (enableValidationLayers && !checkValidationLayerSupport()) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected