summaryrefslogtreecommitdiff
path: root/src/app.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.cpp')
-rw-r--r--src/app.cpp44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 7ef2310..b3df2a5 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -1,21 +1,45 @@
+#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);
-GLFWwindow *start_up(int width, int height) {
- return nullptr;
+ 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(GLFWwindow *window) {
+void shut_down(std::unique_ptr<iris::Swapchain>& swapchain) {
+ ImGui_ImplVulkan_Shutdown();
+ glfwDestroyWindow(swapchain->window);
+ glfwTerminate();
}
int main(int argc, char** argv) {
@@ -51,13 +75,11 @@ int main(int argc, char** argv) {
return -1;
}
- auto window = start_up(window_width, window_height);
- if (window == nullptr) {
- return -2;
+ auto swapchain = start_up(window_width, window_height);
+ while (!glfwWindowShouldClose(swapchain->window)) {
+ main_loop(swapchain->window);
}
- while (!glfwWindowShouldClose(window)) {
- main_loop(window);
- }
- shut_down(window);
+
+ shut_down(swapchain);
return 0;
} \ No newline at end of file