Microsoft DirectX 8.1 (Visual Basic) |
Processing the vertices in a vertex buffer applies the current transformation matrices for the device, and it can optionally apply vertex operations such as lighting, generating clip flags, and updating extents. When using fixed function vertex processing, modifying the elements in the destination vertex buffer is controlled by the D3DPV_DONOTCOPYDATA flag. This flag applies only to fixed function vertex processing. The Direct3DDevice8 class exposes the Direct3DDevice8.ProcessVertices method to process vertices. You process vertices from a vertex shader to the set of input data streams, generating a single stream of interleaved vertex data to the destination vertex buffer by calling the ProcessVertices method. The method accepts five parameters that describe the location and quantity of vertices that the method targets, the destination vertex buffer, and the processing options. After the call, the destination buffer contains the processed vertex data.
The first, second, and third parameters, SrcStartIndex, DestIndex, and VertexCount, reflect the index of the first vertex to load, the index in the destination buffer at which the vertices will be placed, and the total number of vertices to process and place in the destination buffer. The fourth parameter, DestBuffer, should be set to the Direct3DVertexBuffer8 of the vertex buffer object that will receive the source vertices. The SrcStartIndex specifies the index at which the method should start processing vertices.
The final parameter, Flags, determines special processing options for the method. You can set this parameter to 0 for default vertex processing, or to D3DPV_DONOTCOPYDATA to optimize processing in some situations. When you set Flags to 0, vertex components of the destination vertex buffer's vertex format that are not affected by the vertex operation are still copied from the vertex shader or set to 0. However, when using D3DPV_DONOTCOPYDATA, ProcessVertices does not overwrite color and texture coordinate information in the destination buffer unless this data is generated by Microsoft® Direct3D®. Diffuse color is generated when lighting is enabled, that is, D3DRS_LIGHTING is set to 1. Specular color is generated when lighting is enabled and specular is enabled, that is, D3DRS_SPECULARENABLE and D3DRS_LIGHTING are set to 1. Specular color is also generated when fog is enabled. Texture coordinates are generated when texture transform or texture generation is enabled. ProcessVertices uses the current render states to determine what vertex processing should be done.
To determine the vertex processing limitations of a device, query the VertexProcessingCaps member of the D3DCAPS8 structure for its supported vertex processing capabilities.
The Direct3DDevice8.ProcessVertices method requires specific settings for the Flexible Vertex Format Flags of the destination vertex buffer. The flexible vertex format (FVF) usage settings must be compatible with the current settings for vertex processing.
For fixed function vertex processing, ProcessVertices requires the following FVF settings.
In addition, the texture coordinate count must be set in the following manner.
Thus, for each texture stage, a new set of texture coordinates is generated if a texture is bound to that stage and any of the following conditions are 1.
When Direct3D is generating texture coordinates, the application is required to perform the following actions.
Finally, texture coordinate dimensionality (D3DFVF_TEX0 through D3DFVF_TEX8) must be set in the following manner.
When ProcessVertices fails due to an incompatible destination vertex buffer FVF code, the expected code is printed to the debug output (debug builds only).