#include "Application.h" #include #include #include #include #include #include #include #include #include "VulkanRenderer.h" namespace Lunar { Application::Application() { if (!SDL_Init(SDL_INIT_VIDEO)) { std::println(std::cerr, "Failed to initialize SDL."); throw std::runtime_error("App init fail"); } m_window = SDL_CreateWindow( "Lunar", 1280, 720, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE); if (!m_window) { m_logger.err("Failed to create SDL window"); throw std::runtime_error("App init fail"); } m_renderer = std::make_unique(m_window, m_logger); m_logger.info("App init done!"); } Application::~Application() { m_renderer.reset(); SDL_DestroyWindow(m_window); SDL_Quit(); m_logger.info("App destroy done!"); } auto Application::run() -> void { SDL_Event e; while (m_running) { while (SDL_PollEvent(&e)) { if (e.type == SDL_EVENT_QUIT) { m_running = false; } else if (e.type == SDL_EVENT_WINDOW_RESIZED) { int width {}, height {}; SDL_GetWindowSize(m_window, &width, &height); m_renderer->resize(static_cast(width), static_cast(height)); } ImGui_ImplSDL3_ProcessEvent(&e); } ImGui_ImplSDL3_NewFrame(); ImGui_ImplVulkan_NewFrame(); ImGui::NewFrame(); ImGui::ShowDemoWindow(); ImGui::Render(); m_renderer->render(); } } } // namespace Lunar