In our Android example, we will draw the same vertices as the last WebGL example.
46 vertices = new float[] { 47 // Vetex coordinate 48 -150.0f, -150.0f, -1.0f, 49 // Vertex color (R, G, B, α) 50 1.0f, 0.0f, 0.0f, 1.0f, 51 150.0f, -150.0f, -1.0f, 52 0.0f, 1.0f, 0.0f, 1.0f, 53 0.0f, 150.0f, -1.0f, 54 0.0f, 0.0f, 1.0f, 1.0f 55 }; 56 57 moreVertices = new float[] { 58 -150.0f, -150.0f, -2.0f, 59 0.0f, 0.0f, 1.0f, 1.0f, 60 150.0f, -150.0f, -2.0f, 61 0.0f, 1.0f, 0.0f, 1.0f, 62 0.0f, 150.0f, -2.0f, 63 1.0f, 0.0f, 0.0f, 1.0f 64 };
Just like in the WebGL case, the first triangle fills the view, and obscures the second triangle. Java, however, gives us strongly typed variables, and as we will soon see, more structured code.