MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / finishFrame

Method finishFrame

source/MRViewer/ImGuiMenu.cpp:336–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334}
335
336void ImGuiMenu::finishFrame()
337{
338 MR_TIMER;
339 draw_menu();
340 prevFrameFocusPlugin_ = nullptr;
341 if ( context_ && !context_->WindowsFocusOrder.empty() && !ImGui::IsPopupOpen( "", ImGuiPopupFlags_AnyPopup ) )
342 {
343 for ( int i = context_->WindowsFocusOrder.size() - 1; i >= 0; --i )
344 {
345 auto* win = context_->WindowsFocusOrder[i];
346 if ( win && win->Active && std::string( win->Name ).find( StateBasePlugin::UINameSuffix() ) != std::string::npos )
347 {
348 prevFrameFocusPlugin_ = win;
349 break;
350 }
351 }
352 }
353 ProgressBar::onFrameEnd();
354 if ( viewer->isGLInitialized() )
355 {
356 ImGui::Render();
357 ImGui_ImplOpenGL3_RenderDrawData( ImGui::GetDrawData() );
358
359 if ( ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable )
360 {
361 GLFWwindow* backup_current_context = glfwGetCurrentContext();
362 ImGui::UpdatePlatformWindows();
363
364 if ( context_ )
365 {
366 for ( int i = 1; i < context_->Viewports.Size; ++i )
367 {
368 const auto* vp = context_->Viewports[i];
369 // if non-main viewport will be deleted in following frames we force redraw of main frame
370 // to ensure that there is at least one frame when both removed viewport and main viewport renders the window
371 if ( vp->LastFrameActive < context_->FrameCount )
372 {
373 viewer->forceSwapOnFrame();
374 break;
375 }
376 }
377
378 if ( viewer->isCurrentFrameSwapping() )
379 {
380 ImGui::RenderPlatformWindowsDefault();
381
382 // if in swapping frame new viewport appears deffer swapping for main viewport for one frame
383 // to ensure that there is at least one frame when both new viewport and main viewport renders the window
384 static int prevViewports = context_->Viewports.Size;
385 if ( context_->Viewports.Size > prevViewports )
386 viewer->incrementForceRedrawFrames( 1, true );
387 prevViewports = context_->Viewports.Size;
388 }
389 }
390 glfwMakeContextCurrent( backup_current_context );
391 }
392 }
393 else

Callers 1

drawFullMethod · 0.80

Calls 7

onFrameEndFunction · 0.85
forceSwapOnFrameMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected