@@ -1733,22 +1733,31 @@ void MockGLEngine::hideWindow() {}
17331733
17341734void MockGLEngine::updateWindowSize (bool force) {
17351735
1736- // this silly code mimicks the gl backend version, but it is important that we preserve
1736+ // This silly code mimicks the gl backend version, but it is important that we preserve
17371737 // the view::bufferWidth, etc, otherwise it is impossible to manually set the window size
1738- // in the mock backend (which appears in unit tests, etc)
1739- int newBufferWidth = view::bufferWidth;
1740- int newBufferHeight = view::bufferHeight;
1738+ // in the mock backend (which appears in unit tests, etc).
1739+ // In this case, we just let the buffer size follow the window size 1:1
1740+ int newBufferWidth = view::windowWidth;
1741+ int newBufferHeight = view::windowHeight;
17411742 int newWindowWidth = view::windowWidth;
17421743 int newWindowHeight = view::windowHeight;
17431744
17441745 if (force || newBufferWidth != view::bufferWidth || newBufferHeight != view::bufferHeight ||
17451746 newWindowHeight != view::windowHeight || newWindowWidth != view::windowWidth) {
17461747 // Basically a resize callback
17471748 requestRedraw ();
1749+
1750+ // prevent any division by zero for e.g. aspect ratio calcs
1751+ if (newBufferHeight == 0 ) newBufferHeight = 1 ;
1752+ if (newWindowHeight == 0 ) newWindowHeight = 1 ;
1753+
17481754 view::bufferWidth = newBufferWidth;
17491755 view::bufferHeight = newBufferHeight;
17501756 view::windowWidth = newWindowWidth;
17511757 view::windowHeight = newWindowHeight;
1758+
1759+ render::engine->resizeScreenBuffers ();
1760+ render::engine->setScreenBufferViewports ();
17521761 }
17531762}
17541763
0 commit comments