1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0030469: Visualization - Draw crashes when 3D view is minimized

OpenGl_View::Redraw() - avoid rendering into window of zero size (leading to FPE and other issues).
This commit is contained in:
kgv 2019-02-01 16:20:24 +03:00 committed by bugmaster
parent 98ae54f728
commit d918208af6
2 changed files with 17 additions and 8 deletions

View File

@ -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);
}
// =======================================================================

View File

@ -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