1. Four pyramid: consisting of 4 triangles.
Square Body: composed of 6 triangles.
Difficulty: When building the vertex coordinates of a 3D space, you must always have the center coordinate of the object (0.0f,0.0f,0.0f) to rotate the object around its own axis.
And the triangles are plotted in a counter-clockwise order.
2.3D Space Drawing:
Gl_apicall void Gl_apientry gldrawarrays (glenum mode, glint-I, glsizei count);
Parameter description:
mode, drawing mode, OpenGL2.0 later, the following parameters are provided: Gl_points, Gl_lines, Gl_line_loop, Gl_line_strip, Gl_triangles, Gl_triangle_strip, Gl_ Triangle_fan.
First, which one from the array cache begins to draw, typically 0.
Count, the number of vertices in the array.
3. Draw Vertex Array:
Draw Triangle Cone
for (int i=0; i<4; i++)
{
Gl.gldrawarrays (Gl10.gl_triangle_strip, i*3, 3);
}
Draw Square Body
for (int i=0; i<6; i++)
{
Gl.gldrawarrays (Gl10.gl_triangle_strip, i*4, 4);
}
[Attach] Build an array of vertices:
[Java]
int one = 0x10000;
Four pyramid vertex arrays:
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,-one,-one,
0,one,0,
-one,-one,-one,
-one,-one,one
});
Square Body Vertex array:
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,
-one,-one,one,
-one,-one,-one,
One, one,-one,
One, one, one,
One,-one,-one,
One,-one, one,
});
int one = 0x10000;
Four pyramid vertex arrays:
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,-one,-one,
0,one,0,
-one,-one,-one,
-one,-one,one
});
Square Body Vertex array:
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,
-one,-one,one,
-one,-one,-one,
One, one,-one,
One, one, one,
One,-one,-one,
One,-one, one,
});