DirectX9 创建顶点和索引缓存
来源:互联网 发布:折线统计图数据举例 编辑:程序博客网 时间:2024/06/01 10:28
C++ 创建顶点和索引缓存
A vertex buffer is simply a chunk of contiguous memory that contains vertex data. Similarly, an index buffer is a chunk of contiguous memory that contains index data.
We can create a vertex and index buffer with the following two methods:
HRESULT IDirect3DDevice9::CreateVertexBuffer(
UINT Length,
DWORD Usage,
DWORD FVF,
D3DPOOL Pool
IDirect3DVertexBuffer9** ppVertexBuffer,
HANDLE* pSharedHandle
);
HRESULT IDirect3DDevice9::CreateIndexBuffer(
UINT Length,
DWORD Usage,
D3DFORMAT Format,
D3DPOOL Pool,
IDirect3DIndexBuffer9** ppIndexBuffer,
HANDLE* pSharedHandle
);
The majority of the parameters are identical for both methods, so let’s cover the parameters of both methods together.
Length—The number of bytes to allocate for the buffer. If we wanted a vertex buffer to have enough memory to store eight vertices, we would set this parameter to8 * sizeof(Vertex), whereVertexis our vertex structure.
Usage—Specifies some additional properties about how the buffer is used. This value can be zero, indicating no additional properties, or a combination of one or more of the following flags:
D3DUSAGE_DYNAMIC—Setting this flag makes the bufferdynamic. See the notes on static and dynamic buffers on the following page.
D3DUSAGE_POINTS—This flag specifies that the buffer will hold point primitives. Point primitives are covered in “Particle Systems” in Chapter 14. This flag is used only for vertex buffers.
D3DUSAGE_SOFTWAREPROCESSING—Vertex processing is done in software.
D3DUSAGE_WRITEONLY—Specifies that the application will only write to the buffer. This allows the driver to place the buffer in the best memory location for write operations. Note that reading from a buffer created with this flag will result in an error.
FVF—The flexible vertex format of the vertices that is stored in the vertex buffer
Pool—The memory pool in which the buffer is placed
ppVertexBuffer—Pointer to receive the created vertex buffer
pSharedHandle—Not used; set to zero
Format—Specifies the size of the indices; useD3DFMT_INDEX16 for 16-bit indices or useD3DFMT_INDEX32for 32-bit indices. Note that not all devices support 32-bit indices; check the device capabilities.
ppIndexBuffer—Pointer to receive the created index buffer
The following example creates a static vertex buffer that has enough memory to hold eight vertices of typeVertex.
IDirect3DVertexBuffer9* vb;
_device->CreateVertexBuffer(
8 * sizeof( Vertex ),
0,
D3DFVF_XYZ,
D3DPOOL_MANAGED,
&vb,
0);
This next code example shows how to create a dynamic index buffer that has enough memory to hold 36 16-bit indices.
IDirect3DIndexBuffer9* ib;
_device->CreateIndexBuffer(
36 * sizeof( WORD ),
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
D3DFMT_INDEX16,
D3DPOOL_MANAGED,
&ib,
0);
- DirectX9 创建顶点和索引缓存
- 顶点缓存和索引缓存
- DirectX9 检索关于顶点和索引的信息
- 顶点/索引缓存绘制
- XNA学习笔记——顶点缓存和索引缓存
- DX中使用顶点缓存和索引缓存绘制图形
- Direct3D使用顶点缓存和索引缓存进行绘制
- DirectX11 创建顶点缓存
- direct顶点缓存与索引缓存Direct3D
- DirectX9 顶点格式
- DirectX9 索引
- Directx11 顶点以及索引顶点缓存的的应用1
- DirectX 3D_基础之顶点缓存 索引缓存 访问缓存 颜色表示 顶点颜色 着色
- XNA学习笔记——用顶点缓冲和索引缓冲创建地形
- 基于一个顶点缓冲和一个索引缓冲创建一个地形
- 索引顶点
- 索引顶点
- 顶点缓存
- dataTables-使用详细说明整理
- LeetCode 204-Count Primes
- HDU2838 Cow Sorting【树状数组】【逆序数】
- Fedora21 入门体验笔记
- 三级网络ip
- DirectX9 创建顶点和索引缓存
- 练习随笔
- main(int argc,char *argv[] )参数输入
- 剑指offer-19 二叉树的镜像
- 百度算法更新之后对外链的要求解析
- hdu 1874 畅通工程续
- VMware虚拟机设置centos固定ip地址
- Tomcat相关
- 拷贝构造函数