| 40 | } |
| 41 | |
| 42 | bool ImGuiLayer::initialize(GLFWwindow* window, const float content_scale) { |
| 43 | if (initialized_) { |
| 44 | return true; |
| 45 | } |
| 46 | if (window == nullptr) { |
| 47 | return false; |
| 48 | } |
| 49 | |
| 50 | window_ = window; |
| 51 | content_scale_ = content_scale; |
| 52 | |
| 53 | IMGUI_CHECKVERSION(); |
| 54 | ImGui::CreateContext(); |
| 55 | ImGui::StyleColorsDark(); |
| 56 | setup_ui_fonts(content_scale); |
| 57 | |
| 58 | if (!ImGui_ImplGlfw_InitForOpenGL(window, true)) { |
| 59 | ImGui::DestroyContext(); |
| 60 | return false; |
| 61 | } |
| 62 | |
| 63 | oid::platform::install_input_workarounds(window); |
| 64 | |
| 65 | if (!ImGui_ImplOpenGL3_Init(oid::platform::imgui_glsl_version())) { |
| 66 | ImGui_ImplGlfw_Shutdown(); |
| 67 | ImGui::DestroyContext(); |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | initialized_ = true; |
| 72 | return true; |
| 73 | } |
| 74 | |
| 75 | void ImGuiLayer::begin_frame() { |
| 76 | // Size the canvas/GLFW window BEFORE ImGui_ImplGlfw_NewFrame: the |
no test coverage detected