MCPcopy Create free account
hub / github.com/XJTU-Graphics/dandelion / init_ui

Method init_ui

src/platform/platform.cpp:197–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197bool 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
224void Platform::on_framebuffer_resized(
225 [[maybe_unused]] GLFWwindow* window, GLsizei width, GLsizei height

Callers

nothing calls this directly

Calls 7

ImGui_ImplOpenGL3_InitFunction · 0.85
AddFontFromFileTTFMethod · 0.80
warnMethod · 0.80
ScaleAllSizesMethod · 0.80
ClearMethod · 0.45

Tested by

no test coverage detected