From: kgv Date: Sun, 7 Aug 2016 09:05:39 +0000 (+0300) Subject: 0027755: Visualization, V3d_View::ToPixMap() - fix image dump with MSAA turned on X-Git-Tag: V7_1_0_beta~206 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=521b0d7f81a3fb15d2239334668b0366d4197dc2 0027755: Visualization, V3d_View::ToPixMap() - fix image dump with MSAA turned on OpenGl_View::Redraw() now handles correctly myTransientDrawToFront with MSAA turned on and resolution not equal to window size. --- diff --git a/src/OpenGl/OpenGl_View_Redraw.cxx b/src/OpenGl/OpenGl_View_Redraw.cxx index c5f48768d9..7478fbbb1e 100644 --- a/src/OpenGl/OpenGl_View_Redraw.cxx +++ b/src/OpenGl/OpenGl_View_Redraw.cxx @@ -318,13 +318,23 @@ void OpenGl_View::Redraw() || myMainSceneFbos[0]->GetVPSizeY() != aSizeY || myMainSceneFbos[0]->NbSamples() != aNbSamples) { + if (!myTransientDrawToFront) + { + myImmediateSceneFbos[0]->Release (aCtx.operator->()); + myImmediateSceneFbos[1]->Release (aCtx.operator->()); + myImmediateSceneFbos[0]->ChangeViewport (0, 0); + myImmediateSceneFbos[1]->ChangeViewport (0, 0); + } + // prepare FBOs containing main scene // for further blitting and rendering immediate presentations on top if (aCtx->core20fwd != NULL) { myMainSceneFbos[0]->Init (aCtx, aSizeX, aSizeY, myFboColorFormat, myFboDepthFormat, aNbSamples); } - if (!aCtx->caps->useSystemBuffer && myMainSceneFbos[0]->IsValid()) + if (myTransientDrawToFront + && !aCtx->caps->useSystemBuffer + && myMainSceneFbos[0]->IsValid()) { myImmediateSceneFbos[0]->InitLazy (aCtx, *myMainSceneFbos[0]); } @@ -434,6 +444,10 @@ void OpenGl_View::Redraw() { anImmFbo = myImmediateSceneFbos[0].operator->(); } + if (!myTransientDrawToFront) + { + anImmFbo = aMainFbo; + } #if !defined(GL_ES_VERSION_2_0) if (aMainFbo == NULL @@ -708,7 +722,8 @@ bool OpenGl_View::redrawImmediate (const Graphic3d_Camera::Projection theProject { Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext(); GLboolean toCopyBackToFront = GL_FALSE; - if (!myTransientDrawToFront) + if (theDrawFbo == theReadFbo + && theDrawFbo != NULL) { myBackBufferRestored = Standard_False; } @@ -1339,6 +1354,7 @@ void OpenGl_View::bindDefaultFbo (OpenGl_FrameBuffer* theCustomFbo) if (anFbo != NULL) { anFbo->BindBuffer (aCtx); + anFbo->SetupViewport (aCtx); } else { @@ -1350,8 +1366,8 @@ void OpenGl_View::bindDefaultFbo (OpenGl_FrameBuffer* theCustomFbo) aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER); } #endif + aCtx->core11fwd->glViewport (0, 0, myWindow->Width(), myWindow->Height()); } - aCtx->core11fwd->glViewport (0, 0, myWindow->Width(), myWindow->Height()); } // ======================================================================= diff --git a/tests/v3d/glsl/msaa b/tests/v3d/glsl/msaa index 6885beec3b..e66097eb56 100644 --- a/tests/v3d/glsl/msaa +++ b/tests/v3d/glsl/msaa @@ -15,10 +15,28 @@ vrotate 0.5 0 0 vzbufftrihedron vrenderparams -msaa 0 -vdump $::imagedir/${::casename}_0.png +vdump $::imagedir/${::casename}_512x512@msaa0.png vrenderparams -msaa 2 -vdump $::imagedir/${::casename}_2.png +vdump $::imagedir/${::casename}_512x512@msaa2.png vrenderparams -msaa 4 -vdump $::imagedir/${::casename}_4.png +vdump $::imagedir/${::casename}_512x512@msaa4.png vrenderparams -msaa 8 -vdump $::imagedir/${::casename}_8.png +vdump $::imagedir/${::casename}_512x512@msaa8.png + +# check dump with resolutions not equal to window size +vdump $::imagedir/${::casename}_1920x1080@msaa8.png -width 1920 -height 1080 +vdump $::imagedir/${::casename}_2560x1440@msaa8.png -width 2560 -height 1440 + +# check dump with stereo +vstereo anaglyph +vdump $::imagedir/${::casename}_512x512@msaa8stereo.png -stereo blend +vdump $::imagedir/${::casename}_1920x1080@msaa8stereo.png -width 1920 -height 1080 -stereo blend +vdump $::imagedir/${::casename}_2560x1440@msaa8stereo.png -width 2560 -height 1440 -stereo blend + +vraytrace 1 +vsetdispmode b 1 +vdump $::imagedir/${::casename}_512x512@msaa8stereort.png -stereo blend +vdump $::imagedir/${::casename}_1920x1080@msaa8stereort.png -width 1920 -height 1080 -stereo blend +vdump $::imagedir/${::casename}_2560x1440@msaa8stereort.png -width 2560 -height 1440 -stereo blend +vsetdispmode b 0 +vraytrace 0