在Direct3D中挣扎顶点和索引缓冲区 [英] Struggling With Vertex And Index Buffers In Direct3D

查看:156
本文介绍了在Direct3D中挣扎顶点和索引缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了好几个月来了解 IDirect3DVertexBuffer9 IDirect3DIndexBuffer9 工作。我读了多本书,电子书和论坛,我仍然不能得到他们的工作方式。

I've tried for many months to learn how IDirect3DVertexBuffer9 and IDirect3DIndexBuffer9 work. I've read multiple books, e-books and forums and I still can't get the hang of how they work. Can somebody help me understand how they work and how they link together?

PS:我试过搜索相关问题,但没有感兴趣的。

PS: I've tried searching through the related questions but nothing interested me.

感谢。

推荐答案

IndexBuffers用于内存和速度优化。 indexbuffer是一个索引列表,用于索引vertexBuffer中的顶点。

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

所以说我要在屏幕上用2个三角形渲染一个平面四边形。每个三角形占据3个顶点,所以要渲染的四边形只有一个VertexBuffer我将需要6个顶点。

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.

现在如果我使用IndexBuffer虽然,我只需要使用4个顶点(每个角的一个四边形)。但是我需要6个索引,每个三角形有3个索引,它们将索引其中一个顶点。

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.

在大型模型上,这可以节省内存。大大提高了速度,因为GPU将处理较少的顶点。

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

这里是一个网站有一些很好的示例代码:: http://www.codesampler.com/dx9src.htm
在其中下载称为索引几何的示例。

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

这篇关于在Direct3D中挣扎顶点和索引缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆