| 458 | } |
| 459 | |
| 460 | void ImGuiWidget::drawFramebufferCommon(const Vec& fbSize, const float scaleFactor) |
| 461 | { |
| 462 | ImGui::SetCurrentContext(imData->context); |
| 463 | ImGuiIO& io(ImGui::GetIO()); |
| 464 | |
| 465 | if (d_isNotEqual(imData->scaleFactor, scaleFactor)) |
| 466 | { |
| 467 | imData->scaleFactor = scaleFactor; |
| 468 | |
| 469 | ImGuiStyle& style(ImGui::GetStyle()); |
| 470 | new(&style)ImGuiStyle(); |
| 471 | imData->resetStyle(); |
| 472 | |
| 473 | if (! imData->fontGenerated) |
| 474 | { |
| 475 | imData->originalScaleFactor = scaleFactor; |
| 476 | imData->generateFontIfNeeded(); |
| 477 | } |
| 478 | else |
| 479 | { |
| 480 | io.FontGlobalScale = scaleFactor / imData->originalScaleFactor; |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | #if defined(DGL_USE_OPENGL3) |
| 485 | // TODO? |
| 486 | #else |
| 487 | glMatrixMode(GL_PROJECTION); |
| 488 | glPushMatrix(); |
| 489 | glLoadIdentity(); |
| 490 | glOrtho(0.0, box.size.x * scaleFactor, box.size.y * scaleFactor, 0.0, -1.0, 1.0); |
| 491 | glViewport(0.0, 0.0, fbSize.x, fbSize.y); |
| 492 | glMatrixMode(GL_MODELVIEW); |
| 493 | glPushMatrix(); |
| 494 | glLoadIdentity(); |
| 495 | |
| 496 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 497 | glClear(GL_COLOR_BUFFER_BIT); |
| 498 | #endif |
| 499 | |
| 500 | io.DisplaySize = ImVec2(box.size.x * scaleFactor, box.size.y * scaleFactor); |
| 501 | io.DisplayFramebufferScale = ImVec2(fbSize.x / (box.size.x * scaleFactor), fbSize.y / (box.size.y * scaleFactor)); |
| 502 | |
| 503 | if (!imData->created) |
| 504 | { |
| 505 | #if defined(DGL_USE_OPENGL3) |
| 506 | ImGui_ImplOpenGL3_Init(); |
| 507 | #else |
| 508 | ImGui_ImplOpenGL2_Init(); |
| 509 | #endif |
| 510 | imData->created = true; |
| 511 | } |
| 512 | |
| 513 | const double time = glfwGetTime(); |
| 514 | io.DeltaTime = time - imData->lastFrameTime; |
| 515 | imData->lastFrameTime = time; |
| 516 | |
| 517 | #if defined(DGL_USE_OPENGL3) |
nothing calls this directly
no test coverage detected