Android graphics --- OpenGL (V)

Source: Internet
Author: User

Previous: http://www.bkjia.com/kf/201206/137160.html

Appearance and discount of shapes

In OpenGL, the appearance of a shape is defined by more points in three or three dimensions. A set of three or more 3D points (called vertices in OpenGL) can be divided into front and back. How can we know which is the front and which is the back? To answer this question, we need to use a break or define the direction of the point in the shape.

 


Figure 1. The figure shows a list of coordinates that are converted into a counter-clockwise drawing order.

In this example, the points of a triangle are defined in the order they are drawn counterclockwise. These plots use the sequence of coordinates to define the direction of the points. By default, the area drawn counterclockwise in OpenGL is the front. Figure 1. The triangle definition shown in the figure shows the front of the graph (as OpenGL explains), and the other edges are the back.

Why is it important to know the aspect of a graph? This is related to the Face Culling function in OpenGL. Face Culling is an optional feature of the OpenGL environment. It allows the rendering pipeline to ignore (not compute or draw) The back of the image during storage, memory, and processing cycle:

// Enable face culling feature

Gl. glable (GL10.GL _ CULL_FACE );

// Specify which faces to not draw

Gl. glCullFace (GL10.GL _ BACK );

If you try to use the Face filter function, but you do not know that the edges are the front and back of the shape, the OpenGL image looks a little thin, or the image is not displayed at all. Therefore, the coordinates of OpenGL images must always be defined in a counterclockwise order.

Note: You can also use clockwise sequence as the front to set the OpenGL environment. However, this requires more code and can cause confusion for OpenGL developers. Therefore, do not do this.

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.