1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#include "vulkan_swapchain.h"
#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_vulkan.h"
#include "argparse/argparse.hpp"
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <vector>
std::unique_ptr<iris::Swapchain> start_up(int width, int height) {
auto glfw_extensions = get_glfw_instance_extensions();
// std::vector<const char*> glfw_extensions = {
// "VK_KHR_surface",
// };
// for (const auto& extension : glfw_extensions) {
// std::cerr << "GLFW extension: " << extension << std::endl;
// }
iris::Device device({}, glfw_extensions);
auto window = glfwCreateWindow(width, height, "IrisRenderer", nullptr, nullptr);
if (window == nullptr) {
std::cerr << "Failed to create GLFW window" << std::endl;
abort();
}
return std::make_unique<iris::Swapchain>(window, device);
}
void main_loop(GLFWwindow *window) {
(void) window;
}
void shut_down(std::unique_ptr<iris::Swapchain>& swapchain) {
ImGui_ImplVulkan_Shutdown();
glfwDestroyWindow(swapchain->window);
glfwTerminate();
}
int main(int argc, char** argv) {
argparse::ArgumentParser program("IrisRenderer");
program.add_argument("width")
.help("display width of the window")
.scan<'i', int>();
program.add_argument("height")
.help("display height of the window")
.scan<'i', int>();
try {
program.parse_args(argc, argv);
} catch (const std::exception& err) {
std::cerr << err.what() << std::endl;
std::cerr << program;
return 1;
}
int window_width = program.get<int>("width");
int window_height = program.get<int>("height");
if (!glfwInit()) {
const char* description = nullptr;
glfwGetError(&description);
if (description != nullptr) {
std::cerr << "Error: " << description << std::endl;
} else {
std::cerr << "Failed to initialize GLFW" << std::endl;
}
glfwTerminate();
return -1;
}
auto swapchain = start_up(window_width, window_height);
while (!glfwWindowShouldClose(swapchain->window)) {
main_loop(swapchain->window);
}
shut_down(swapchain);
return 0;
}
|