Game Development Reference
In-Depth Information
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; use D3DFMT_INDEX16
for 16-bit indices or use D3DFMT_INDEX32 for 32-bit indices. Note
that not all devices support 32-bit indices; check the device
capabilities.
ppIndexBuffer —Pointer to receive the created index buffer
Note: A buffer created without the D3DUSAGE_DYNAMIC flag is called
a static buffer . Static buffers are generally placed in video memory
where its contents can be processed most efficiently. However, the
trade-off of making a buffer static is that writing to and reading from
the memory of a static buffer is inherently slow because accessing
video memory is slow. For this reason we use static buffers to hold
static data (data that will not need to be changed (accessed) very fre-
quently). Terrains and city buildings are examples of good candidates
for static buffers because the terrain and building geometry will usually
not change during the course of the application. Static buffers should
be filled with geometry at application initialization time and never at
run time.
Note: A buffer created with the D3DUSAGE_DYNAMIC flag is called a
dynamic buffer . Dynamic buffers are generally placed in AGP memory
where its memory can be updated quickly. Dynamic buffers are not
processed as quickly as static buffers because the data must be trans-
ferred to video memory before rendering, but the benefit of dynamic
buffers is that they can be updated reasonably fast (fast CPU writes).
Therefore, if you need to update the contents of a buffer frequently, it
should be made dynamic. Particle systems are good candidates for
dynamic buffers because they are animated, and thus their geometry
is usually updated every frame.
Note: Reading video memory and AGP memory from your applica-
tion is very slow. Therefore, if you need to read your geometry at run
time, it is best to keep a local system memory copy and then read from
that.
The following example creates a static vertex buffer that has enough
memory to hold eight vertices of type Vertex .
IDirect3DVertexBuffer9* vb;
_device->CreateVertexBuffer(
8 * sizeof( Vertex ),
0,
D3DFVF_XYZ,
D3DPOOL_MANAGED,
Search WWH ::




Custom Search