From 3fd33ecff7472e4d6fc9e6b3905f56982e497ef2 Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 23 Aug 2026 17:21:37 +0200 Subject: [feat]: complete RHI api --- src/core/window.cpp | 105 +--------------------------------------------------- 1 file changed, 1 insertion(+), 104 deletions(-) (limited to 'src/core/window.cpp') diff --git a/src/core/window.cpp b/src/core/window.cpp index 047ef0d..dd5882c 100644 --- a/src/core/window.cpp +++ b/src/core/window.cpp @@ -1,14 +1,8 @@ -#include #include "window.h" -#include "theme_manager.h" -#include "rendering/renderer.h" // RendererAPI::get_api() +#include "rendering/render_api.h" // RendererAPI::get_api() #include -#include -#include -#include - namespace Donut { static bool s_glfw_initialized = false; @@ -94,8 +88,6 @@ namespace Donut { DONUT_INFO("Shutting down window: ", m_title); - shutdown_im_gui(); - glfwDestroyWindow(m_window); s_glfw_window_count--; @@ -133,101 +125,6 @@ namespace Donut GLFW_CURSOR_NORMAL : GLFW_CURSOR_HIDDEN); } - auto Window::init_im_gui() -> void - { - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); - io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; - io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; -#ifndef __APPLE__ - // Multi-viewport (dragging ImGui panels out as separate OS windows) - // relies on a populated platform-monitor list and is unreliable on - // macOS, where it intermittently asserts (Monitors.Size > 0) and - // aborts. Docking stays enabled; panels just remain inside the window. - io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; -#endif - - setup_im_gui_fonts(); - ThemeManager::set_theme(Theme::Dark); - - ImGuiStyle& style = ImGui::GetStyle(); - if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) - { - style.WindowRounding = 0.0f; - style.Colors[ImGuiCol_WindowBg].w = 1.0f; - } - - ImGui_ImplGlfw_InitForOpenGL(m_window, true); -#ifdef __APPLE__ - // macOS uses a core-profile context, which rejects the legacy - // "#version 130" GLSL the ImGui backend defaults to. 150 is the - // minimum core-profile GLSL that macOS's OpenGL 4.1 accepts. - ImGui_ImplOpenGL3_Init("#version 150"); -#else - ImGui_ImplOpenGL3_Init("#version 130"); -#endif - - DONUT_INFO("ImGUI initialized successfully"); - } - - auto Window::setup_im_gui_fonts() -> void - { - ImGuiIO& io = ImGui::GetIO(); - io.Fonts->Clear(); - - m_main_font = io.Fonts->AddFontFromFileTTF("assets/fonts/inter/static/Inter_18pt-Regular.ttf", 16.0f); - if (!m_main_font) - { - DONUT_WARN("Failed to load Inter font, falling back to default"); - m_main_font = io.Fonts->AddFontDefault(); - } - else - DONUT_INFO("Successfully loaded Inter font"); - - m_large_font = io.Fonts->AddFontFromFileTTF("assets/fonts/inter/static/Inter_18pt-Bold.ttf", 20.0f); - if (!m_large_font) - m_large_font = m_main_font; - - m_small_font = io.Fonts->AddFontFromFileTTF("assets/fonts/inter/static/Inter_18pt-Light.ttf", 12.0f); - if (!m_small_font) - m_small_font = m_main_font; - - io.FontDefault = m_main_font; - DONUT_INFO("ImGUI fonts loaded successfully"); - } - - auto Window::shutdown_im_gui() -> void - { - ImGui_ImplOpenGL3_Shutdown(); - ImGui_ImplGlfw_Shutdown(); - ImGui::DestroyContext(); - - DONUT_INFO("ImGUI shutdown"); - } - - auto Window::begin_im_gui_frame() -> void - { - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplGlfw_NewFrame(); - ImGui::NewFrame(); - } - - auto Window::end_im_gui_frame() -> void - { - ImGui::Render(); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); - - ImGuiIO& io = ImGui::GetIO(); - if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) - { - GLFWwindow* backup_current_context = glfwGetCurrentContext(); - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); - glfwMakeContextCurrent(backup_current_context); - } - } - auto Window::glfw_error_callback(int error, const char* description) -> void { DONUT_ERROR("GLFW Error ({}): {}", error, description ? description : ""); -- cgit v1.3