Struggling With Vertex And Index Buffers In Direct3D

后端 未结 2 728
耶瑟儿~
耶瑟儿~ 2021-02-03 11:59

I\'ve tried for many months to learn how IDirect3DVertexBuffer9 and IDirect3DIndexBuffer9 work. I\'ve read multiple books, e-books and forums and I sti

2条回答
  •  旧时难觅i
    2021-02-03 12:31

    IndexBuffers are used for memory & speed optimizations. A indexBuffer is a list of indices that index the vertices in the vertexBuffer.

    So say I'm going to render a Flat Quad on the screen with 2 triangles. Each triangle takes up 3 vertices, so to render the quad with just a VertexBuffer I will need 6 vertices.

    Now if I use a IndexBuffer though, I would only need to use 4 vertices(one for each corner of the quad). But I would need 6 indices, 3 indices for each triangle, that will index one of the corner vertices.

    On large models this can save memory & greatly improve speed as the GPU will be processing fewer vertices.

    Here is a site with some good sample code:: http://www.codesampler.com/dx9src.htm In there download the sample called "Indexed Geometry".

提交回复
热议问题