2020-02-03 23:23:47 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#define GLFW_INCLUDE_VULKAN
|
|
|
|
#include "GLFW/glfw3.h"
|
|
|
|
|
|
|
|
#include "../src/VkBootstrap.h"
|
|
|
|
|
2020-05-19 17:10:50 +00:00
|
|
|
GLFWwindow* create_window_glfw (const char * window_name = "", bool resize = true) {
|
2020-02-03 23:23:47 +00:00
|
|
|
glfwInit ();
|
|
|
|
glfwWindowHint (GLFW_CLIENT_API, GLFW_NO_API);
|
2020-02-04 03:34:46 +00:00
|
|
|
if (!resize) glfwWindowHint (GLFW_RESIZABLE, GLFW_FALSE);
|
|
|
|
|
2020-06-08 22:59:31 +00:00
|
|
|
return glfwCreateWindow (1024,1024, window_name, NULL, NULL);
|
2020-02-03 23:23:47 +00:00
|
|
|
}
|
2020-02-18 22:18:08 +00:00
|
|
|
void destroy_window_glfw (GLFWwindow* window) {
|
2020-02-03 23:23:47 +00:00
|
|
|
glfwDestroyWindow (window);
|
|
|
|
glfwTerminate ();
|
|
|
|
}
|
2020-02-18 22:18:08 +00:00
|
|
|
VkSurfaceKHR create_surface_glfw (VkInstance instance, GLFWwindow* window) {
|
2020-02-03 23:23:47 +00:00
|
|
|
VkSurfaceKHR surface = nullptr;
|
|
|
|
VkResult err = glfwCreateWindowSurface (instance, window, NULL, &surface);
|
2020-02-18 22:18:08 +00:00
|
|
|
if (err) {
|
2020-02-03 23:23:47 +00:00
|
|
|
const char* error_msg;
|
|
|
|
int ret = glfwGetError (&error_msg);
|
2020-02-18 22:18:08 +00:00
|
|
|
if (ret != 0) {
|
2020-02-03 23:23:47 +00:00
|
|
|
std::cout << ret << " ";
|
|
|
|
if (error_msg != nullptr) std::cout << error_msg;
|
|
|
|
std::cout << "\n";
|
|
|
|
}
|
|
|
|
surface = nullptr;
|
|
|
|
}
|
|
|
|
return surface;
|
2020-02-18 22:18:08 +00:00
|
|
|
}
|
|
|
|
void destroy_surface (VkInstance instance, VkSurfaceKHR surface) {
|
|
|
|
vkDestroySurfaceKHR (instance, surface, nullptr);
|
2020-02-03 23:23:47 +00:00
|
|
|
}
|