Platform SDK: DirectX |
There are two common situations in which your application will render vertices from a vertex buffer. At the most basic level, the two situations break down according to the type of vertex that is in the vertex buffer at "render time," but indirectly, the procedure your application uses also determines when vertex and rendering operations occur. Note that applications must use vertex buffer methods when rendering from a vertex buffer. The following diagram illustrates the process of rendering from an untransformed vertex buffer.
As shown in the preceding illustration, the IDirect3DDevice7::DrawPrimitiveVB and IDirect3DDevice7::DrawIndexedPrimitiveVB methods are capable of rendering from a non-transformed vertex buffer. In this case, the system performs vertex and rendering operations each time you call a rendering method. Using this approach isn't likely to provide improved performance over traditional DrawPrimitive rendering methods, but it might be more convenient in some situations. You can optimize performance by reusing transformed vertex data when you can, as shown in the following illustration.
As shown in the preceding illustration, the Direct3DDevice7.DrawPrimitiveVB and Direct3DDevice7.DrawIndexedPrimitiveVB Visual Basic methods are capable of rendering from a non-transformed vertex buffer. In this case, the system performs vertex and rendering operations each time you call a rendering method. Using this approach isn't likely to provide improved performance over traditional DrawPrimitive rendering methods, but it might be more convenient in some situations. You can optimize performance by reusing transformed vertex data when you can, as shown in the following illustration.
In this case, your application creates two vertex buffers: one for untransformed geometry, and another for transformed geometry. The second buffer receives transformed vertex data when the IDirect3DVertexBuffer7::ProcessVertices is called. The ProcessVertices method reads the vertices in the source buffer, performs the requested vertex operations on them, and places the results in the destination buffer. You can call the same rendering methods for transformed vertices that you would to render untransformed vertices. However, unlike untransformed vertices, Direct3D automatically detects that the data in the vertex buffer is transformed, sending it be rasterized right away. The performance overhead is kept to a minimum by eliminating unnecessary transformations.
Note The IDirect3DVertexBuffer7 interface provides a new method, IDirect3DVertexBuffer7::ProcessVerticesStrided, to process strided vertices into a destination vertex buffer.
In this case, your application creates two vertex buffers: one for untransformed geometry, and another for transformed geometry. The second buffer receives transformed vertex data when the Direct3DVertexBuffer7.ProcessVertices is called. The ProcessVertices method reads the vertices in the source buffer, performs the requested vertex operations on them, and places the results in the destination buffer. You can call the same rendering methods for transformed vertices that you would to render untransformed vertices. However, unlike untransformed vertices, Direct3D automatically detects that the data in the vertex buffer is transformed, sending it be rasterized right away. The performance overhead is kept to a minimum by eliminating unnecessary transformations.
You can optimize vertex buffer contents to increase performance even more. For more information, see Optimizing a Vertex Buffer.