diff options
author | Chuyan Zhang <me@zcy.moe> | 2024-09-06 01:50:30 -0700 |
---|---|---|
committer | Chuyan Zhang <me@zcy.moe> | 2024-09-06 01:50:30 -0700 |
commit | e12ca33626bdadedc3158cb69f2a4d2f9bbeeeb0 (patch) | |
tree | 1e7803cbdd48b8a2de355916f042f7b77325f920 /src/app.cpp | |
parent | 8c7926588b616988e7b016eaf704acee0ee77cc9 (diff) | |
download | iris-e12ca33626bdadedc3158cb69f2a4d2f9bbeeeb0.tar.gz iris-e12ca33626bdadedc3158cb69f2a4d2f9bbeeeb0.zip |
setup swapchain
Diffstat (limited to 'src/app.cpp')
-rw-r--r-- | src/app.cpp | 44 |
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 |