Hopefully created vulkan surface.
This commit is contained in:
parent
87d20ff820
commit
25eb1f8e54
1 changed files with 13 additions and 0 deletions
13
src/main.c
13
src/main.c
|
|
@ -38,6 +38,7 @@ typedef struct Application {
|
|||
VkPhysicalDevice physicalDevice;
|
||||
VkDevice device;
|
||||
VkQueue graphicsQueue;
|
||||
VkSurfaceKHR surface;
|
||||
} Application;
|
||||
|
||||
bool checkValidationLayerSupport() {
|
||||
|
|
@ -325,16 +326,27 @@ void initVulkan(Application *app) {
|
|||
pickPhysicalDevice(app);
|
||||
createLogicalDevice(app);
|
||||
}
|
||||
|
||||
void createSurface(Application *app) {
|
||||
if (glfwCreateWindowSurface(app->instance, app->window, NULL,
|
||||
&app->surface) != VK_SUCCESS) {
|
||||
fprintf(stderr, "Error creating vulkan surface in glfw window.");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void mainLoop(Application *app) {
|
||||
while (!glfwWindowShouldClose(app->window)) {
|
||||
glfwPollEvents();
|
||||
}
|
||||
}
|
||||
|
||||
void cleanup(Application *app) {
|
||||
vkDestroyDevice(app->device, NULL);
|
||||
if (enableValidationLayers) {
|
||||
DestroyDebugUtilsMessengerEXT(app->instance, app->debugMessenger, NULL);
|
||||
}
|
||||
vkDestroySurfaceKHR(app->instance, app->surface, NULL);
|
||||
vkDestroyInstance(app->instance, NULL);
|
||||
glfwDestroyWindow(app->window);
|
||||
glfwTerminate();
|
||||
|
|
@ -345,6 +357,7 @@ int main(void) {
|
|||
|
||||
initWindow(&app);
|
||||
initVulkan(&app);
|
||||
createSurface(&app);
|
||||
mainLoop(&app);
|
||||
cleanup(&app);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue