Graphics Programs Reference
In-Depth Information
Note You may wonder exactly how we specify the type of primit-
ive(s) we intend to render on the OpenGL surface. We do this inside
the onDrawFrame method, using ES 2.0 functions— glDrawAr-
rays or glDrawElements . These functions take primitive-type
( GL_POINTS , GL_LINES , or GL_TRIANGLES ) as an argument.
We deal with glDrawArrays within this section.
gl_Position is a special built-in variable. If the vertex shader does not write to it,
the graphics pipeline won't know of the vertex (of an object) we intend to render on
the OpenGL surface. Considering the OpenGL world is similar to Figure 3-6 , when
we set gl_Position as vec4(0.0, 0.0, 0.0, 1) , we define a point at
the center of OpenGL surface ( Figure 3-8 ). You may have understood already that
vec4 is a four-component vector (not to be confused with the physical quantity
“vector”), representing a 3D point in the OpenGL world. The last component in the
vector vec4(0.0, 0.0, 0.0, 1) does not represent any visualizable quantity.
It is added as a practical tool to enable matrix multiplications for various 3D-Trans-
formations (you can read more about this at http://stackoverflow.com/a/
2465290 ). If this vec4 were to represent a “vector” quantity (not a 3D point), then,
in place of '1,' we have to append '0' as the last component.
Figure 3-8 . Point sprite
 
 
Search WWH ::




Custom Search