mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0028127: Visualization - transparent object breaks Z-Layer depth buffer clear
OpenGl_LayerList::Render() now calls glDepthMask(GL_TRUE) before clearing depth buffer. Depth buffer is now cleared even if ZLayer with this command has no structures.
This commit is contained in:
parent
5299b92ba1
commit
b3eab8efc3
@ -663,12 +663,7 @@ void OpenGl_Layer::Render (const Handle(OpenGl_Workspace)& theWorkspace,
|
|||||||
const OpenGl_GlobalLayerSettings& theDefaultSettings) const
|
const OpenGl_GlobalLayerSettings& theDefaultSettings) const
|
||||||
{
|
{
|
||||||
const Graphic3d_PolygonOffset anAppliedOffsetParams = theWorkspace->AppliedPolygonOffset();
|
const Graphic3d_PolygonOffset anAppliedOffsetParams = theWorkspace->AppliedPolygonOffset();
|
||||||
|
// myLayerSettings.ToClearDepth() is handled outside
|
||||||
// separate depth buffers
|
|
||||||
if (myLayerSettings.ToClearDepth())
|
|
||||||
{
|
|
||||||
glClear (GL_DEPTH_BUFFER_BIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle depth test
|
// handle depth test
|
||||||
if (myLayerSettings.ToEnableDepthTest())
|
if (myLayerSettings.ToEnableDepthTest())
|
||||||
|
@ -387,6 +387,7 @@ void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace)& theWorkspace,
|
|||||||
aCtx->core11fwd->glGetBooleanv (GL_DEPTH_WRITEMASK, &aDefaultSettings.DepthMask);
|
aCtx->core11fwd->glGetBooleanv (GL_DEPTH_WRITEMASK, &aDefaultSettings.DepthMask);
|
||||||
|
|
||||||
Standard_Integer aSeqId = myLayers.Lower();
|
Standard_Integer aSeqId = myLayers.Lower();
|
||||||
|
bool toClearDepth = false;
|
||||||
for (OpenGl_SequenceOfLayers::Iterator anIts (myLayers); anIts.More(); anIts.Next(), ++aSeqId)
|
for (OpenGl_SequenceOfLayers::Iterator anIts (myLayers); anIts.More(); anIts.Next(), ++aSeqId)
|
||||||
{
|
{
|
||||||
if (theLayersToProcess == OpenGl_LF_Bottom)
|
if (theLayersToProcess == OpenGl_LF_Bottom)
|
||||||
@ -403,29 +404,35 @@ void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace)& theWorkspace,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const OpenGl_Layer& aLayer = anIts.Value();
|
const OpenGl_Layer& aLayer = anIts.Value();
|
||||||
if (aLayer.NbStructures() < 1)
|
if (aLayer.IsImmediate() != theToDrawImmediate)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (theToDrawImmediate)
|
else if (aLayer.NbStructures() < 1)
|
||||||
{
|
{
|
||||||
if (!aLayer.IsImmediate())
|
// make sure to clear depth of previous layers even if layer has no structures
|
||||||
{
|
toClearDepth = toClearDepth || aLayer.LayerSettings().ToClearDepth();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
// depth buffers
|
||||||
{
|
if (toClearDepth
|
||||||
if (aLayer.IsImmediate())
|
|| aLayer.LayerSettings().ToClearDepth())
|
||||||
{
|
{
|
||||||
continue;
|
toClearDepth = false;
|
||||||
}
|
glDepthMask (GL_TRUE);
|
||||||
|
glClear (GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// render layer
|
|
||||||
aLayer.Render (theWorkspace, aDefaultSettings);
|
aLayer.Render (theWorkspace, aDefaultSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (toClearDepth)
|
||||||
|
{
|
||||||
|
glDepthMask (GL_TRUE);
|
||||||
|
glClear (GL_DEPTH_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
aCtx->core11fwd->glDepthMask (aDefaultSettings.DepthMask);
|
aCtx->core11fwd->glDepthMask (aDefaultSettings.DepthMask);
|
||||||
aCtx->core11fwd->glDepthFunc (aDefaultSettings.DepthFunc);
|
aCtx->core11fwd->glDepthFunc (aDefaultSettings.DepthFunc);
|
||||||
}
|
}
|
||||||
|
29
tests/bugs/vis/bug28127
Normal file
29
tests/bugs/vis/bug28127
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
puts "==========="
|
||||||
|
puts "OCC28127"
|
||||||
|
puts "Visualization - transparent object breaks Z-Layer depth buffer clear"
|
||||||
|
puts "==========="
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
pload MODELING VISUALIZATION
|
||||||
|
box r 0 0 0 1 0.1 1
|
||||||
|
box g 0 0.2 0 1 0.1 1
|
||||||
|
box b 0 0.4 0 1 0.1 1
|
||||||
|
|
||||||
|
vclear
|
||||||
|
vinit View1
|
||||||
|
vaxo
|
||||||
|
vdisplay -noupdate -dispMode 1 -top r g b
|
||||||
|
vsetcolor -noupdate r RED
|
||||||
|
vsetcolor -noupdate g GREEN
|
||||||
|
vsetcolor -noupdate b BLUE1
|
||||||
|
vfit
|
||||||
|
|
||||||
|
vdisplay -topmost g
|
||||||
|
vzbufftrihedron -on -position left_upper
|
||||||
|
|
||||||
|
vsettransparency b 0.5
|
||||||
|
|
||||||
|
if { [vreadpixel 150 150 rgb name] != "GREEN3" } { puts "Error: wrong color - GREEN box should overlap RED one" }
|
||||||
|
if { [vreadpixel 84 64 rgb name] == "RED3" } { puts "Error: wrong color - Trihedron should overlap RED box" }
|
||||||
|
|
||||||
|
vdump $imagedir/${casename}.png
|
Loading…
x
Reference in New Issue
Block a user