-
Notifications
You must be signed in to change notification settings - Fork 25
/
depth
73 lines (62 loc) · 2.61 KB
/
depth
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Do not erase the depth buffer before a selection rendering.
This permits to not have to draw all the scene to check the visibility of an element.
See http://www.vtk.org/Bug/view.php?id=7296
A fix has been included in CVS HEAD, so this patch has been rewritten
as a backport in VTK 5.2, maybe it will be accepted upstream.
Unfortunately this means that ClearDepthForSelection has to be
replaced by PreserveDepthBuffer (with inverse meaning) in Java sources.
---
Rendering/vtkOpenGLRenderer.cxx | 7 +++++--
Rendering/vtkRenderer.cxx | 1 +
Rendering/vtkRenderer.h | 8 ++++++++
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Rendering/vtkOpenGLRenderer.cxx b/Rendering/vtkOpenGLRenderer.cxx
index ca3793a..b9168f7 100644
--- a/Rendering/vtkOpenGLRenderer.cxx
+++ b/Rendering/vtkOpenGLRenderer.cxx
@@ -1103,8 +1103,11 @@ void vtkOpenGLRenderer::Clear(void)
clear_mask |= GL_COLOR_BUFFER_BIT;
}
- glClearDepth(static_cast<GLclampf>(1.0));
- clear_mask |= GL_DEPTH_BUFFER_BIT;
+ if (!this->GetPreserveDepthBuffer())
+ {
+ glClearDepth(static_cast<GLclampf>(1.0));
+ clear_mask |= GL_DEPTH_BUFFER_BIT;
+ }
vtkDebugMacro(<< "glClear\n");
glClear(clear_mask);
diff --git a/Rendering/vtkRenderer.cxx b/Rendering/vtkRenderer.cxx
index d7c22e9..642fa80 100644
--- a/Rendering/vtkRenderer.cxx
+++ b/Rendering/vtkRenderer.cxx
@@ -87,6 +87,7 @@ vtkRenderer::vtkRenderer()
this->PathArrayCount = 0;
this->Layer = 0;
+ this->PreserveDepthBuffer = 0;
this->ComputedVisiblePropBounds[0] = VTK_DOUBLE_MAX;
this->ComputedVisiblePropBounds[1] = -VTK_DOUBLE_MAX;
diff --git a/Rendering/vtkRenderer.h b/Rendering/vtkRenderer.h
index a0aae36..1c94e2c 100644
--- a/Rendering/vtkRenderer.h
+++ b/Rendering/vtkRenderer.h
@@ -319,6 +319,13 @@ public:
vtkGetMacro(Layer, int);
// Description:
+ // Normally a renderer is treated as transparent if Layer > 0. To treat a
+ // renderer at Layer 0 as transparent, set this flag to true.
+ vtkSetMacro(PreserveDepthBuffer, int);
+ vtkGetMacro(PreserveDepthBuffer, int);
+ vtkBooleanMacro(PreserveDepthBuffer, int);
+
+ // Description:
// Returns a boolean indicating if this renderer is transparent. It is
// transparent if it is not in the deepest layer of its render window.
int Transparent();
@@ -481,6 +488,7 @@ protected:
// Shows what layer this renderer belongs to. Only of interested when
// there are layered renderers.
int Layer;
+ int PreserveDepthBuffer;
// Holds the result of ComputeVisiblePropBounds so that it is visible from
// wrapped languages