新增窗口管理
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "command_line.h"
|
||||
#include "imgui_impl_sdl3.h"
|
||||
#include "imgui_internal.h"
|
||||
#include "window_manager.h"
|
||||
#include "filesystem/stb_image.h"
|
||||
#include "rhi/texture.h"
|
||||
#include "rhi/renderer.h"
|
||||
@@ -35,27 +36,26 @@ void application::init(const window_params& in_window_params, int argc, char** a
|
||||
|
||||
renderer_->pre_init();
|
||||
|
||||
const auto window = g_window_manager.create_main_window(in_window_params.title.c_str(), in_window_params.width, in_window_params.height);
|
||||
// new glfw window
|
||||
window_ = glfwCreateWindow(in_window_params.width, in_window_params.height, in_window_params.title.c_str(), nullptr,
|
||||
nullptr);
|
||||
if (!window_) {
|
||||
if (!window) {
|
||||
spdlog::error("Failed to create glfw window");
|
||||
return;
|
||||
}
|
||||
|
||||
renderer_->init(window_);
|
||||
renderer_->init(window);
|
||||
g_is_running = true;
|
||||
}
|
||||
|
||||
int application::run() {
|
||||
const ImGuiIO& io = ImGui::GetIO();
|
||||
while (!g_exit_requested) {
|
||||
glfwPollEvents();
|
||||
g_exit_requested = g_exit_requested || glfwWindowShouldClose(window_);
|
||||
g_window_manager.tick();
|
||||
g_exit_requested = g_exit_requested || g_window_manager.should_close();
|
||||
tick(io.DeltaTime);
|
||||
renderer_->new_frame(window_);
|
||||
renderer_->new_frame(g_window_manager.get_main_window());
|
||||
draw_gui();
|
||||
renderer_->end_frame(window_);
|
||||
renderer_->end_frame(g_window_manager.get_main_window());
|
||||
}
|
||||
|
||||
shutdown();
|
||||
@@ -74,6 +74,11 @@ void application::shutdown() {
|
||||
g_is_running = false;
|
||||
}
|
||||
|
||||
void application::request_exit() {
|
||||
g_window_manager.request_exit();
|
||||
g_exit_requested = true;
|
||||
}
|
||||
|
||||
std::shared_ptr<texture> application::load_texture(const std::string& path, vk::Format format) {
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
@@ -116,8 +121,6 @@ void application::init_imgui() {
|
||||
}
|
||||
|
||||
void application::destroy_glfw() {
|
||||
glfwDestroyWindow(window_);
|
||||
window_ = nullptr;
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user