Graphics Programs Reference
In-Depth Information
GLES20.glEnable(GLES20.GL_CULL_FACE);
GLES20.glCullFace(GLES20.GL_BACK);
GLES20.glFrontFace(GLES20.GL_CCW);
First we enable the state GL_CULL_FACE . Then, using the ES 2.0 function
glCullFace , we specify which face has to be culled— GL_FRONT or GL_BACK
( GL_BACK is the default). Finally, using glFrontFace , we specify the orientation
to be made front-facing. As a result, we get the output as shown in Figure 3-23 (in-
stead of the output shown in Figure 3-22 ).
Figure 3-23 . GL CULL FACE application
Depth Test
Apart from the color buffer, there is another kind of framebuffer associated with the
EGL window—depth buffer. It is used for hidden surface removal. For each pixel on
the OpenGL surface, it tracks (object) vertex's distance to the viewer to determine
whether the corresponding fragment's color is retained on the color buffer. There-
fore, if vertex B is behind vertex F, depth buffer stores the position of F (to further
compare with other vertices for that pixel, if any) and stores its fragment correspond-
ing to the matching pixel in color buffer.
An interesting point is that, when we only use a single ES 2.0 program in our
Renderer class, “depth testing” takes place automatically. However, if there are
multiple programs, we need to explicitly enable depth testing by calling
GLES20.glEnable(GLES20.GL_DEPTH_TEST) ”. If we do not enable it, the
 
 
Search WWH ::




Custom Search