Android development of OpenGL ES 3D Space and Gldrawarrays

Source: Internet
Author: User
Tags arrays

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,

});

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.