Chapter 3 Section 8 set Vertex buffers

Source: Internet
Author: User

Set the vertex buffer (Vertex buffer)

In the previous section "convert model coordinates to viewpoint coordinates", all the vertex data of the object to be rendered is packaged in a vertex buffer. The drawprimitive method called in the rendering phase uses the information in the vertex buffer for rendering. The specified primitive type must match the method in which the vertex is placed in the buffer to obtain the desired result.

 

Five Basic primitive types can be used for rendering: point, line, Triangle List, triangle band, and triangle fan. Point elements are used to draw a single pixel on the screen, such as when you want to describe the night sky or the stars in space. Another more popular use is to draw point particles in the example system. (The Particle System willChapter 4Description .) Each vertex in the vertex buffer is a three-dimensional coordinate position with color information. The number of elements of this type is the number of vertices in the buffer.

 

The second primitive, line segment, is used to draw a line segment with a single pixel width between two points in a three-dimensional space. This may be the least used primitive type. Its only use is to overwrite the information displayed in the figure (its only utility is to render "heads-up" display information as part of an overlay ). This element usually appears in two types: linelist and linestrip. List version indicates that each of the two vertices in the buffer is drawn into a line segment. Note that if we draw a line segment list, the number of vertices in the vertex buffer must be an even number. The strip version uses the vertex in the buffer to draw a line segment with a multi-hop segment.

 

The remaining primitive types are most used in 3D games. Draw a triangle using the relationship between triangles. The first is the list of most common event triangles. Every three vertices in the buffer are drawn into a triangle. This method requires a minimum number of settings among the three triangle types. If the triangle adjacent to an object is drawn, we can use this condition to make the adjacent triangle share the common vertex.

 

In this case, if the last two vertices of each triangle in the buffer are the vertices of the last triangle. This is about 66% better than using the Triangle List method, because only 1/3 of vertices are converted to screen coordinates than the previous method. To use such elements, we must follow the rules to model objects and ensure that the buffer is properly filled (packed ). A large number of triangles are used to draw a rectangular area.Figure3-4An example of triangle driving is provided:

 


Figure 3-4:Triangle band

 

The last element is the triangle fan. Fan has the same advantages, but it has a slightly different purpose. In a triangle fan, the first vertex in the buffer is shared with all triangles in the fan. The last vertex of each triangle is shared with the next triangle.Figure3-5An example of a triangle fan is provided:

Figure 3-5Triangle fan

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.