| 1988 | } |
| 1989 | |
| 1990 | void Viewer::postResize( int w, int h ) |
| 1991 | { |
| 1992 | if ( w == 0 || h == 0 ) |
| 1993 | return; |
| 1994 | if ( framebufferSize.x == w && framebufferSize.y == h ) |
| 1995 | return; |
| 1996 | if ( viewport_list.size() == 1 ) |
| 1997 | { |
| 1998 | ViewportRectangle rect( { 0.f, 0.f }, { float( w ), float( h ) } ); |
| 1999 | viewport().setViewportRect( rect ); |
| 2000 | } |
| 2001 | else |
| 2002 | { |
| 2003 | // It is up to the user to define the behavior of the post_resize() function |
| 2004 | // when there are multiple viewports (through the `callback_post_resize` callback) |
| 2005 | if ( w != 0 && h != 0 ) |
| 2006 | for ( auto& viewport : viewport_list ) |
| 2007 | { |
| 2008 | auto rect = viewport.getViewportRect(); |
| 2009 | auto oldWidth = width( rect ); |
| 2010 | auto oldHeight = height( rect ); |
| 2011 | rect.min.x = float( rect.min.x / framebufferSize.x ) * w; |
| 2012 | rect.min.y = float( rect.min.y / framebufferSize.y ) * h; |
| 2013 | rect.max.x = rect.min.x + float( oldWidth / framebufferSize.x ) * w; |
| 2014 | rect.max.y = rect.min.y + float( oldHeight / framebufferSize.y ) * h; |
| 2015 | viewport.setViewportRect( rect ); |
| 2016 | } |
| 2017 | } |
| 2018 | signals_->postResizeSignal( w, h ); |
| 2019 | if ( w != 0 ) |
| 2020 | framebufferSize.x = w; |
| 2021 | if ( h != 0 ) |
| 2022 | framebufferSize.y = h; |
| 2023 | if ( !windowMaximized ) // resize is called after maximized |
| 2024 | windowSaveSize = framebufferSize; |
| 2025 | |
| 2026 | if ( alphaSorter_ ) |
| 2027 | alphaSorter_->updateTransparencyTexturesSize( framebufferSize.x, framebufferSize.y ); |
| 2028 | if ( sceneTexture_ ) |
| 2029 | sceneTexture_->reset( framebufferSize, getMSAAPow( getRequiredMSAA_( true, true ) ), isDepthPeelingEnabled() ); |
| 2030 | if ( depthPeeler_ ) |
| 2031 | depthPeeler_->reset( framebufferSize ); |
| 2032 | |
| 2033 | #if !defined(__EMSCRIPTEN__) || defined(MR_EMSCRIPTEN_ASYNCIFY) |
| 2034 | if ( isLaunched_ && !isInDraw_ ) |
| 2035 | { |
| 2036 | incrementForceRedrawFrames( forceRedrawMinimumIncrementAfterEvents, true ); |
| 2037 | while ( !draw_( true ) ); |
| 2038 | } |
| 2039 | #endif |
| 2040 | |
| 2041 | if ( hasScaledFramebuffer_ ) |
| 2042 | updatePixelRatio_(); |
| 2043 | |
| 2044 | gWindowSizeInitialized = true; |
| 2045 | } |
| 2046 | |
| 2047 | void Viewer::postSetPosition( int xPos, int yPos ) |
no test coverage detected