Graphics Programs Reference
In-Depth Information
+ "}";
As explained in the section “GLSL”, every fragment shader must explicitly declare
a default precision for float types, such as vec4 , which is why there is extra code
at the top of fragment shader in Listing 3-22 . (Refer back to that topic for more on
the basics of data types.)
Triangle Primitive
Like a line primitive, rendering a triangle primitive ( Figure 3-13 ) requires appropri-
ately setting the arguments of the glDrawArrays function. We must specify the
mode as GLES20.GL_TRIANGLES and the count as a multiple of 3 (you get an
imaginary triangle if you set the count to 0!).
Figure 3-13 . Rendering triangle using glDrawArrays
Rendering a triangle primitive is left as an exercise for you, but, in case you find
this difficult, you can import the archive file from the source
code for this chapter. This will load the GL TRIANGLE application into your Eclipse
As previously mentioned, in ES 2.0 we can use a combination of the same type of
primitives to render various objects. Now, let's look at rendering a rectangle using
two triangle primitives.
Search WWH ::

Custom Search