Share via


D3dDrawPrimitives2

This function renders primitives and returns the updated render state.

DWORD (APIENTRY *LPD3DHAL_DRAWPRIMITIVES2CB)(
  LPD3DHAL_DRAWPRIMITIVES2DATA pdp
);

Parameters

  • pdp
    [in] Points to a D3DHAL_DRAWPRIMITIVES2DATA structure that contains the information required for the driver to render one or more primitives.

Return Values

D3dDrawPrimitives2 returns one of the following callback codes:

Remarks

D3dDrawPrimitives2 must be implemented in Direct3D drivers.

The following list shows the actions the driver must perform:

  • Ensure that the context handle specified by the dwhContext member of the D3DHAL_DRAWPRIMITIVES2DATA structure is valid.
  • Check that a flip to the drawing surface associated with the context is not in progress. If the drawing surface is involved in a flip, the driver should set the ddrval member of the following structure to DDERR_WASSTILLDRAWING and return DDHAL_DRIVER_HANDLED.
  • Determine the location where the first D3DHAL_DP2COMMAND structure is found by adding dwCommandOffset bytes to the command buffer to which the lpDDCommands points. dwCommandOffset and lpDDCommands are members of the D3DHAL_DRAWPRIMITIVES2DATA structure.
  • Determine the location in the vertex buffer where the first vertex is found. Perform this action only if there is data in the vertex buffer; that is, when a D3DDP2OP_XXX command token is received, except when the token is D3DDP2OP_LINELIST_IMM or D3DDP2OP_TRIANGLEFAN_IMM. These two opcodes indicate that the vertex data is passed immediately in the command stream, rather than in a vertex buffer. So, assuming there is data in the vertex buffer, if the vertex buffer is in user memory, the first vertex is dwVertexOffset bytes into the buffer to which lpVertices points. Otherwise, the driver should apply dwVertexOffset to the memory associated with the DDRAWI_DDRAWSURFACE_LCL structure to which lpDDVertex points. dwVertexOffset, lpVertices, and lpDDVertex are members of the D3DHAL_DRAWPRIMITIVES2DATA structure.
  • Check the dwVertexType member of the D3DHAL_DRAWPRIMITIVES2DATA structure to ensure that the driver supports the requested FVF (Flexible Vertex Format). The driver should fail the call if any of the following conditions exist:
    • Vertex coordinates are not specified; that is, if D3DFVF_XYZRHW is not set.
    • Normals are specified; that is, if D3DFVF_NORMAL is set.
    • Any of the reserved D3DFVF_RESERVEDx bits are set.
  • Process the commands in the command buffer sequentially. For each D3DHAL_DP2COMMAND structure, the driver should perform the following actions:
    • If the command is D3DDP2OP_RENDERSTATE, process the wStateCount D3DHAL_DP2RENDERSTATE structures that follow in the command buffer, updating the driver state for each render state structure. When the D3DHALDP2_EXECUTEBUFFER flag is set, the driver should also reflect the state change in the array that lpdwRStates points to. wStateCount and lpdwRStates are members of the D3DHAL_DRAWPRIMITIVES2DATA structure.
    • If the command is D3DDP2OP_TEXTURESTAGESTATE, process the wStateCount D3DHAL_DP2TEXTURESTAGESTATE structures that follow in the command buffer, updating the driver's texture state associated with the specified texture stage for each texture state structure.
    • If the command is D3DDP2OP_VIEWPORTINFO, process the D3DHAL_DP2VIEWPORTINFO structure that follows in the command buffer, updating the viewport information stored in the driver's internal rendering context.
    • If the command is D3DDP2OP_WINFO, process the D3DHAL_DP2WINFO structure that follows in the command buffer, updating the w-buffering information stored in the driver's internal rendering context.
    • Otherwise, process the D3DHAL_DP2XXX primitive structures that follow the D3DDP2OP_XXX primitive rendering command in the command buffer.
    • If the command is unknown, call the run time's D3dParseUnknownCommand callback. The run time provides this callback to the driver's GetDriverInfo callback with the GUID_D3DParseUnknownCommandCallback globally unique identifier (GUID).

The driver does not need to probe for readability the memory where the command and vertex buffers are stored. However, the driver must stay within the bounds specified by the dwCommandLength and dwVertexLength members of the D3DHAL_DRAWPRIMITIVES2DATA structure.

If the driver must fail D3dDrawPrimitives2, it should fill in the dwErrorOffset member of the D3DHAL_DRAWPRIMITIVES2DATA structure with the offset into the command buffer where the first unhandled D3DHAL_DP2COMMAND can be found.

Requirements

OS Versions: Windows CE .NET 4.0 and later.
Header: Proto.h.
Link Library: Developer implemented.

See Also

D3DHAL_DRAWPRIMITIVES2DATA | DDHAL_DRIVER_HANDLED | DDHAL_DRIVER_NOTHANDLED | DDERR_WASSTILLDRAWING | D3DHAL_DP2COMMAND | D3DDP2OP_LINELIST_IMM | D3DDP2OP_TRIANGLEFAN_IMM | DDRAWI_DDRAWSURFACE_LCL | D3DDP2OP_RENDERSTATE | D3DHAL_DP2RENDERSTATE | D3DDP2OP_TEXTURESTAGESTATE | D3DHAL_DP2TEXTURESTAGESTATE | D3DDP2OP_VIEWPORTINFO | D3DHAL_DP2VIEWPORTINFO | D3DDP2OP_WINFO | D3DHAL_DP2WINFO | GetDriverInfo | D3DHAL_DP2INDEXEDLINESTRIP | D3DHAL_DP2INDEXEDTRIANGLEFAN | D3DHAL_DP2INDEXEDTRIANGLELIST | D3DHAL_DP2INDEXEDTRIANGLESTRIP | FVF (Flexible Vertex Format) | Direct3D Driver Functions

 Last updated on Tuesday, May 18, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.