MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / drawFramebufferCommon

Method drawFramebufferCommon

plugins/Cardinal/src/ImGuiWidget.cpp:460–535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458}
459
460void 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)

Callers

nothing calls this directly

Calls 15

ImVec2Function · 0.85
ImGui_ImplOpenGL3_InitFunction · 0.85
ImGui_ImplOpenGL2_InitFunction · 0.85
generateFontIfNeededMethod · 0.80
glMatrixModeFunction · 0.50
glLoadIdentityFunction · 0.50
glOrthoFunction · 0.50
glViewportFunction · 0.50

Tested by

no test coverage detected