Computer Graphics (ii) OUTPUT element _10_ polygon Fill Area _7_opengl Polygon fill area function (bottom)

Source: Internet
Author: User

OpenGL Polygon Fill Area function (bottom)

In addition to the primitive functions of triangles and general polygons, OpenGL can also describe two types of quadrilateral. the display results of Figure 3.57 (a) can be generated using the Gl_quads entity constant and the 8 vertices specified in the following two-dimensional coordinate array.

Glbenin (gl_quads); Glvertex2iv (p1); Glvertex2iv (p2); Glvertex2iv (p3); Glvertex2iv (p4); Glvertex2iv (p5); Glvertex2iv (P6); Glvertex2iv (P7); Glvertex2iv (P8); Glend ();
The first four points define a four-sided vertex, and the next four points define the next quadrilateral, and so on. We specify the vertex position in counterclockwise order for each quadrilateral fill area. If there is no duplicate vertex position, a set of unconnected quadrilateral fill areas is displayed. You must list at least four vertices when using the entity, otherwise nothing will be displayed. If the specified number of vertices is not a multiple of 4, the extra vertices are ignored.
Rearranging the set of vertices in the previous Quadrilateral program example and changing the entity constants to Gl_quad_strip, we get a set of contiguous quads in Figure 3.57 (b).
Glbenin (Gl_quad_strip); Glvertex2iv (p1); Glvertex2iv (p2); Glvertex2iv (p4); Glvertex2iv (p3); Glvertex2iv (p5); Glvertex2iv (P6); Glvertex2iv (P8); Glvertex2iv (P7); Glend ();
After specifying two vertices, each quadrilateral is specified with a further two vertices, and we must list the set of vertices that enable each quadrilateral to get the correct counter-clockwise vertex order. At n>=4, n vertices can generate n/2-l quads. If n is not a multiple of 4, the extra coordinate position in the vertex set is not used. We can press N=1, n=2,....., n = n/2-1 to fill polygon and vertex count. In this way, the vertex order of the Nth quadrilateral in the polygon table is 2n-1, 2n, 2n+2, 2n+1. In this example, n=8 thus has three quads to form a band. Therefore, the first quadrilateral (n = 1) has the vertex order (P1, P2, p3, p4). The order of entry points for the second quadrilateral (n=2) is ((P4, P3, P6, p5). The third quadrilateral (n=3) has a vertex order of (P5,P6,P7,P8).
Most graphics packages use approximation planes to display surfaces. This is because the plane equation is linear, and the processing of linear equations is much faster than two or other curve equations. So OpenGL and other graphics packages provide polygon primitives to implement the approximation of the surface. Objects are modeled with a polygon network, and the database of geometry and attribute information is built on the target of processing polygon patches. In OpenGL, the entities that can be used for this purpose are triangular bands (triangle strip), triangular fan (triangle fan), and quadrilateral
Band (quad strip).High-performance graphics systems are drawn using fast polygon hardware, making the display speed up to more than million polygons per second (usually triangles), including the use of surface textures and special lighting effects.

Although OpenGL's core library only allows convex polygons, OpenGL's utility libraries (GLU) provide information about functions that handle concave polygons and other non-convex objects with linear boundaries. You can use a set of Glu polygon fine-molecular programs to convert those shapes into triangles, triangular networks, triangle fans, and straight segments. Once those shapes are broken down, you can use the OpenGL function for processing.


Figure 3.57 shows the quadrilateral fill area with 8 vertices: (a) generating two non-phase gl_quads with a
(b) The formation of three connected quads with a Gl_quad_strip


Computer Graphics (ii) OUTPUT element _10_ polygon Fill Area _7_opengl Polygon fill area function (bottom)

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.