3D game basics direct3d (4) fixed pipeline plotting Elements

Source: Internet
Author: User

What is an element? Primitive

To put it bluntly, it is a set of vertices. These vertices describe a three-dimensional graph. A model produced by 3D Max is actually a set of graphic elements, which are composed of related lighting, materials, and other attributes.

Generally, in d3d and OpenGL, elements are represented by two arrays (or buffer). One is vertex buffer and the other is index buffer ).

Vertex buffer: used to store the original data of vertex coordinates;

Index Buffer: used to store index numbers of vertices of each element. Index Numbers match vertex buffer.

Why is there a vertex array, but we can create another index array ?? This is mainly because many elements may overlap. In this case, if vertices are used for representation, it is a waste of space. However, the index array is clear and efficient. You know, it's very time-consuming to transfer large elements .... You can draw another 3D object by replacing the index array with ease, instead of updating a large fixed-point array at any time.

In d3d, how are elements drawn?

1 first, create the vertex and index Buffer:

Device-> createvertexbuffer ()

Device-> createindexbuffer ()

2. Set the drawing status:

Device-> setrenderstate ()

3. Set the data stream:

Device-> setstreamsource ()

4. Set the vertex format

Device-> setfvf () // the so-called fvf refers to the vertex format, which includes coordinates, materials, and textures.

5. SET index Buffering

Device-> setindices ()

6. Draw Elements

Device-> beginsceen ()

Device-> drawprimitive9 ()

Or

Device-> drqwindexedprimitive ()

Device-> endscene ()

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.