Revision 41a85bb7
Added by Leszek Koltunski almost 6 years ago
src/main/java/org/distorted/examples/stencil/StencilRenderer.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.graphics.Bitmap; |
23 | 23 |
import android.graphics.BitmapFactory; |
24 |
import android.opengl.GLES30;
|
|
24 |
import android.opengl.GLES31;
|
|
25 | 25 |
import android.opengl.GLSurfaceView; |
26 | 26 |
|
27 | 27 |
import org.distorted.examples.R; |
... | ... | |
118 | 118 |
// Nothing - i.e. use default OpenGL settings (one difference - in Distorted, Depth Test is on by default). |
119 | 119 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
120 | 120 |
// Stuff to do just before we render the Floor |
121 |
mFloorNode.glEnable(GLES30.GL_STENCIL_TEST); // Enable Stencil when rendering this Node
|
|
122 |
mFloorNode.glStencilFunc(GLES30.GL_ALWAYS, 1, 0xFF); // Set any stencil to 1
|
|
123 |
mFloorNode.glStencilOp(GLES30.GL_KEEP, GLES30.GL_KEEP, GLES30.GL_REPLACE); // replace with 1 when we fail Depth test
|
|
121 |
mFloorNode.glEnable(GLES31.GL_STENCIL_TEST); // Enable Stencil when rendering this Node
|
|
122 |
mFloorNode.glStencilFunc(GLES31.GL_ALWAYS, 1, 0xFF); // Set any stencil to 1
|
|
123 |
mFloorNode.glStencilOp(GLES31.GL_KEEP, GLES31.GL_KEEP, GLES31.GL_REPLACE); // replace with 1 when we fail Depth test
|
|
124 | 124 |
mFloorNode.glStencilMask(0xFF); // Write to stencil buffer |
125 | 125 |
mFloorNode.glDepthMask(false); // Don't write to depth buffer |
126 |
mFloorNode.glClear(GLES30.GL_STENCIL_BUFFER_BIT); // Clear stencil buffer (by default, with a 0)
|
|
126 |
mFloorNode.glClear(GLES31.GL_STENCIL_BUFFER_BIT); // Clear stencil buffer (by default, with a 0)
|
|
127 | 127 |
|
128 | 128 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
129 | 129 |
// Stuff to do just before we render the lower Cube |
130 |
mCube2Node.glEnable(GLES30.GL_STENCIL_TEST); // Enable Stencil when rendering this Node
|
|
130 |
mCube2Node.glEnable(GLES31.GL_STENCIL_TEST); // Enable Stencil when rendering this Node
|
|
131 | 131 |
// no, this is not retained; we have to set |
132 | 132 |
// this again even though Floor just set it |
133 |
mCube2Node.glStencilFunc(GLES30.GL_EQUAL, 1, 0xFF); // Pass test if stencil value is 1
|
|
133 |
mCube2Node.glStencilFunc(GLES31.GL_EQUAL, 1, 0xFF); // Pass test if stencil value is 1
|
|
134 | 134 |
mCube2Node.glStencilMask(0x00); // Don't write anything to stencil buffer |
135 | 135 |
mCube2Node.glDepthMask(true); // Write to depth buffer |
136 | 136 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Convert everythig to GLES31 (there were some GLES30 remnants)