OpenGL graphics Basic Drawing, it is beginning from the plane to think three-dimensional transfer, now draw a golden Triangle appearance, in fact, the main or fixed-point array of problems, gl10.gl_triangles the main role of this parameter,
Gl_triangles-This parameter means that theOpenGLuse three vertices to compose a graph. So, at the beginning of the three vertices, the vertices will be used1, Vertex2, Vertex3to form a triangle. When finished, the triangle is formed using the next set of three vertices until the end of the array.
So we can use this to draw a golden Triangle, the code is actually not much change, just the vertex array changes:
Golden Triangle Array
Private float[] Mtrianglearray = {
0.0f,1.0f,0.0f,
-1.0f,-1.0f,1.0f,
1.0f,-1.0f,1.0f,
0.0f,1.0f,0.0f,
1.0f,-1.0f,1.0f,
1.0f,-1.0f,-1.0f,
0.0f,1.0f,0.0f,
1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
0.0f,1.0f,0.0f,
-1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,1.0f
};
Golden Triangle Color Array
Private float[] mcolorarray={
1.0f,0.0f,0.0f,1.0f,
0.0f,1.0f,0.0f,1.0f,
0.0f,0.0f,1.0f,1.0f,
1.0f,0.0f,0.0f,1.0f,
0.0f,0.0f,1.0f,1.0f,
0.0f,1.0f,0.0f,1.0f,
1.0f,0.0f,0.0f,1.0f,
0.0f,1.0f,0.0f,1.0f,
0.0f,0.0f,1.0f,1.0f,
1.0f,0.0f,0.0f,1.0f,
0.0f,0.0f,1.0f,1.0f,
0.0f,1.0f,0.0f,1.0f,
};
Then put gl.gldrawarrays (gl10.gl_triangles, 0, 12) at the time of drawing;
The last parameter of this method is changed to 12, because it is drawn with 12 vertices.
This is to draw a golden triangle, and draw a rectangle, that is a little different from this and so on, immediately off work, and so on two days in the study
OpenGL Learning Chapter II