Revision b5636dbf
Added by Leszek Koltunski about 7 years ago
src/main/java/org/distorted/examples/fbo/FBORenderer.java | ||
---|---|---|
56 | 56 |
private DistortedScreen mScreen; |
57 | 57 |
private DistortedNode mRoot; |
58 | 58 |
private int lisaHeight, lisaWidth; |
59 |
private boolean mDepth; |
|
59 | 60 |
|
60 | 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
61 | 62 |
|
62 | 63 |
FBORenderer(GLSurfaceView v) |
63 | 64 |
{ |
64 | 65 |
mView = v; |
66 |
mDepth = true; |
|
65 | 67 |
mEffects= new DistortedEffects(); |
66 | 68 |
mScreen = new DistortedScreen(); |
67 | 69 |
} |
68 | 70 |
|
69 | 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
70 | 72 |
|
71 |
void setDepth(boolean depth) |
|
72 |
{ |
|
73 |
if( mRoot!=null ) |
|
74 |
{ |
|
75 |
if( depth ) mRoot.glEnable (GLES30.GL_DEPTH_TEST); |
|
76 |
else mRoot.glDisable(GLES30.GL_DEPTH_TEST); |
|
73 |
private void setDepthPriv() |
|
74 |
{ |
|
75 |
if( mDepth ) mRoot.glEnable (GLES30.GL_DEPTH_TEST); |
|
76 |
else mRoot.glDisable(GLES30.GL_DEPTH_TEST); |
|
77 | 77 |
|
78 |
mRoot.glDepthMask(depth);
|
|
78 |
mRoot.glDepthMask(mDepth);
|
|
79 | 79 |
|
80 |
// we can also, to save memory, delete/recreate |
|
81 |
// the depth buffer each time. This is optional. |
|
82 |
DistortedFramebuffer fbo = mRoot.getFramebuffer(); |
|
83 |
fbo.enableDepth(depth); |
|
84 |
} |
|
80 |
// we can also, to save memory, delete/recreate |
|
81 |
// the depth buffer each time. This is optional. |
|
82 |
DistortedFramebuffer fbo = mRoot.getFramebuffer(); |
|
83 |
if( fbo!=null ) fbo.enableDepth(mDepth); |
|
84 |
} |
|
85 |
|
|
86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
87 |
|
|
88 |
void setDepth(boolean depth) |
|
89 |
{ |
|
90 |
mDepth = depth; |
|
91 |
if( mRoot!=null ) setDepthPriv(); |
|
85 | 92 |
} |
86 | 93 |
|
87 | 94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
161 | 168 |
mRoot = new DistortedNode(lisa, mEffects,new MeshFlat(1,1)); |
162 | 169 |
mRoot.attach(grid,gridEffects,new MeshCubes(10,10,false)); |
163 | 170 |
|
171 |
setDepthPriv(); |
|
172 |
|
|
164 | 173 |
mScreen.detachAll(); |
165 | 174 |
mScreen.attach(mRoot); |
166 | 175 |
|
Also available in: Unified diff
Improve Dynamic and FBO apps.