Graphics Programs Reference
In-Depth Information
Figure 3-14 . Rendering rectangle using triangle primitives
Normalized Device Coordinate System
To simplify things, OpenGL ES assumes that the vertices specified for primitives
( Listing 3-24 ) are for a 3D world, which is a normalized cube, so that all points in
this cube lie within the range [1, 1, 1] to [-1, -1, -1] . To see this, import
the archive file ndc.zip from the source code for this chapter.
Listing 3-24. NDC/src/com/apress/android/ndc/GLES20Renderer.java
float triangleVFA[] = {
-1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f
};
If you read the Renderer class of the NDC application, you will see that it is trying
to render a triangle primitive. Inside the initShapes method, the float array
( triangleVFA ) for position is defined as shown in Listing 3-24 .
When you run this application, you get output similar to Figures 3-15 and 3-16 (for
portrait and landscape modes respectively). As mentioned, OpenGL ES assumes that
the vertices specified for triangle primitive are for a normalized cube world. When
graphics are rendered using OpenGL ES, this cube world is projected onto the (rect-
 
 
 
 
Search WWH ::




Custom Search