| 195 | } |
| 196 | |
| 197 | bool Platform::init_ui() |
| 198 | { |
| 199 | // Initialize Dear ImGui context |
| 200 | if (!IMGUI_CHECKVERSION()) |
| 201 | return false; |
| 202 | if (ImGui::CreateContext() == nullptr) |
| 203 | return false; |
| 204 | ImGuiIO& io = ImGui::GetIO(); |
| 205 | io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; |
| 206 | // Load the Source Han Sans SC font and scale all UI elements by `scale_factor' |
| 207 | io.Fonts->Clear(); |
| 208 | ImFont* source_han_sans = io.Fonts->AddFontFromFileTTF( |
| 209 | "resources/SourceHanSansSC-Regular.otf", 18.0f * scale_factor, nullptr, |
| 210 | io.Fonts->GetGlyphRangesChineseSimplifiedCommon() |
| 211 | ); |
| 212 | if (source_han_sans == nullptr) { |
| 213 | logger->warn("Source Han Sans not found, drop back to the default font"); |
| 214 | } |
| 215 | // Device-dependent initial configurations for Dear ImGui. |
| 216 | ImGuiStyle& style = ImGui::GetStyle(); |
| 217 | style.ScaleAllSizes(scale_factor); |
| 218 | ImGui_ImplGlfw_InitForOpenGL(window, true); |
| 219 | ImGui_ImplOpenGL3_Init("#version 330"); |
| 220 | |
| 221 | return true; |
| 222 | } |
| 223 | |
| 224 | void Platform::on_framebuffer_resized( |
| 225 | [[maybe_unused]] GLFWwindow* window, GLsizei width, GLsizei height |
nothing calls this directly
no test coverage detected