1. Four pyramid: composed of four triangles.
Ry: consists of six triangles.
Difficulty: when constructing the vertex coordinates of a 3D space, to make the object rotate around its own axis, the central coordinates of the object must always be (0.0f, 0.0f, 0.0f ),
And the triangles are drawn in a counter-clockwise order.
2.3D space rendering:
GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count );
Parameter description:
Mode: drawing method. The following parameters are provided after OpenGL2.0: GL_POINTS, GL_LINES, GL_LINE_LOOP, GL_LINE_STRIP, GL_TRIANGLES, GL_TRIANGLE_STRIP, and GL_TRIANGLE_FAN.
First, which position in the array cache is drawn, generally 0.
Count, number of vertices in the array.
3. Draw the vertex array:
// Draw a triangle cone
For (int I = 0; I <4; I ++)
{
Gl. glDrawArrays (GL10.GL _ TRIANGLE_STRIP, I * 3, 3 );
}
// Draw a ry
For (int I = 0; I <6; I ++)
{
Gl. glDrawArrays (GL10.GL _ TRIANGLE_STRIP, I * 4, 4 );
}
[Appendix] constructing vertex Arrays:
[Java]
Int one = 0x10000;
// An array of four pyramid vertices:
Private IntBuffer triggerBuffer = IntBuffer. wrap (new int [] {
0, one, 0,
-One,-one, 0,
One,-one, one,
0, one, 0,
One,-one, one,
One,-one,-one,
0, one, 0,
One,-one,-one,
-One,
0, one, 0,
-One,
-One,-one, one
});
// An array of Four-body vertices:
Private IntBuffer quaterBuffer = IntBuffer. wrap (new int [] {
One, one,-one,
-One, one,-one,
One,
-One,
One,-one, one,
-One,-one, one,
One,-one,-one,
-One,
One,
-One,
One,-one, one,
-One,-one, one,
One,-one,-one,
-One,
One, one,-one,
-One, one,-one,
-One,
-One, one,-one,
-One,-one, one,
-One,
One, one,-one,
One,
One,-one,-one,
One,-one, one,
});
Int one = 0x10000;
// An array of four pyramid vertices:
Private IntBuffer triggerBuffer = IntBuffer. wrap (new int [] {
0, one, 0,
-One,-one, 0,
One,-one, one,
0, one, 0,
One,-one, one,
One,-one,-one,
0, one, 0,
One,-one,-one,
-One,
0, one, 0,
-One,
-One,-one, one
});
// An array of Four-body vertices:
Private IntBuffer quaterBuffer = IntBuffer. wrap (new int [] {
One, one,-one,
-One, one,-one,
One,
-One,
One,-one, one,
-One,-one, one,
One,-one,-one,
-One,
One,
-One,
One,-one, one,
-One,-one, one,
One,-one,-one,
-One,
One, one,-one,
-One, one,-one,
-One,
-One, one,-one,
-One,-one, one,
-One,
One, one,-one,
One,
One,-one,-one,
One,-one, one,
});