diff --git a/src/OpenGl/OpenGl_BVHTreeSelector.cxx b/src/OpenGl/OpenGl_BVHTreeSelector.cxx index a3bcd1edd3..95edcad41f 100644 --- a/src/OpenGl/OpenGl_BVHTreeSelector.cxx +++ b/src/OpenGl/OpenGl_BVHTreeSelector.cxx @@ -96,10 +96,10 @@ void OpenGl_BVHTreeSelector::SetViewportSize (Standard_Integer theViewportWidth, Standard_Integer theViewportHeight, Standard_Real theResolutionRatio) { - myViewportHeight = theViewportHeight; - myViewportWidth = theViewportWidth; - myPixelSize = Max (theResolutionRatio / theViewportHeight, - theResolutionRatio / theViewportWidth); + myViewportHeight = theViewportHeight > 0 ? theViewportHeight : 1; + myViewportWidth = theViewportWidth > 0 ? theViewportWidth : 1; + myPixelSize = Max (theResolutionRatio / myViewportHeight, + theResolutionRatio / myViewportWidth); } // ======================================================================= diff --git a/src/OpenGl/OpenGl_View_Redraw.cxx b/src/OpenGl/OpenGl_View_Redraw.cxx index b88fcd15a4..2a6c5d1153 100644 --- a/src/OpenGl/OpenGl_View_Redraw.cxx +++ b/src/OpenGl/OpenGl_View_Redraw.cxx @@ -179,10 +179,19 @@ void OpenGl_View::Redraw() && !aCtx->caps->buffersNoSwap && aFrameBuffer == NULL; - Standard_Integer aSizeX = aFrameBuffer != NULL ? aFrameBuffer->GetVPSizeX() : myWindow->Width(); - Standard_Integer aSizeY = aFrameBuffer != NULL ? aFrameBuffer->GetVPSizeY() : myWindow->Height(); - Standard_Integer aRendSizeX = Standard_Integer(myRenderParams.RenderResolutionScale * aSizeX + 0.5f); - Standard_Integer aRendSizeY = Standard_Integer(myRenderParams.RenderResolutionScale * aSizeY + 0.5f); + const Standard_Integer aSizeX = aFrameBuffer != NULL ? aFrameBuffer->GetVPSizeX() : myWindow->Width(); + const Standard_Integer aSizeY = aFrameBuffer != NULL ? aFrameBuffer->GetVPSizeY() : myWindow->Height(); + const Standard_Integer aRendSizeX = Standard_Integer(myRenderParams.RenderResolutionScale * aSizeX + 0.5f); + const Standard_Integer aRendSizeY = Standard_Integer(myRenderParams.RenderResolutionScale * aSizeY + 0.5f); + if (aSizeX < 1 + || aSizeY < 1 + || aRendSizeX < 1 + || aRendSizeY < 1) + { + myBackBufferRestored = Standard_False; + myIsImmediateDrawn = Standard_False; + return; + } // determine multisampling parameters Standard_Integer aNbSamples = !myToDisableMSAA && aSizeX == aRendSizeX