完成实例创建
							parent
							
								
									5657b90883
								
							
						
					
					
						commit
						edf8c19af6
					
				| 
						 | 
					@ -13,6 +13,52 @@ GLFWwindow* HelloTriangleApplication::initWindow(int Width, int Height) {
 | 
				
			||||||
	return window;
 | 
						return window;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void HelloTriangleApplication::createInstance() {
 | 
				
			||||||
 | 
						VkApplicationInfo appInfo = {};
 | 
				
			||||||
 | 
						appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
 | 
				
			||||||
 | 
						appInfo.pApplicationName = "Hello Triangle";
 | 
				
			||||||
 | 
						appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
 | 
				
			||||||
 | 
						appInfo.pEngineName = "No_Engine";
 | 
				
			||||||
 | 
						appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
 | 
				
			||||||
 | 
						appInfo.apiVersion = VK_API_VERSION_1_0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						VkInstanceCreateInfo createInfo = {};
 | 
				
			||||||
 | 
						createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
 | 
				
			||||||
 | 
						createInfo.pApplicationInfo = &appInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						uint32_t glfwExtentionCount = 0;
 | 
				
			||||||
 | 
						const char** glfwExtensions;
 | 
				
			||||||
 | 
						glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtentionCount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						createInfo.enabledExtensionCount = glfwExtentionCount;
 | 
				
			||||||
 | 
						createInfo.ppEnabledExtensionNames = glfwExtensions;
 | 
				
			||||||
 | 
						createInfo.enabledLayerCount = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (vkCreateInstance(&createInfo, nullptr, &instance)!=VK_SUCCESS)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							throw std::runtime_error("failed to create instance");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						uint32_t extensionCount = 0;
 | 
				
			||||||
 | 
						vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						std::vector<VkExtensionProperties> extensions(extensionCount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensions.data());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						std::cout << "available extensions :" << std::endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (const auto& extension : extensions)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							std::cout << "\t" << extension.extensionName << " version:" << extension.specVersion << std::endl;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void HelloTriangleApplication::initVulkan() {
 | 
				
			||||||
 | 
						createInstance();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void HelloTriangleApplication::mainLoop(GLFWwindow* window){
 | 
					void HelloTriangleApplication::mainLoop(GLFWwindow* window){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (!glfwWindowShouldClose(window))
 | 
						while (!glfwWindowShouldClose(window))
 | 
				
			||||||
| 
						 | 
					@ -23,6 +69,9 @@ void HelloTriangleApplication::mainLoop(GLFWwindow* window){
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void HelloTriangleApplication::cleanup(GLFWwindow* window) {
 | 
					void HelloTriangleApplication::cleanup(GLFWwindow* window) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						vkDestroyInstance(instance, nullptr);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	glfwDestroyWindow(window);
 | 
						glfwDestroyWindow(window);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	glfwTerminate();
 | 
						glfwTerminate();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,10 +27,14 @@ public:
 | 
				
			||||||
		cleanup(window);
 | 
							cleanup(window);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	GLFWwindow* initWindow(int Width, int Height);
 | 
					 | 
				
			||||||
	void initVulkan() {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						VkInstance instance;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						GLFWwindow* initWindow(int Width, int Height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void createInstance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void initVulkan();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void mainLoop(GLFWwindow* window);
 | 
						void mainLoop(GLFWwindow* window);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue