|
|
D3DPT_TRIANGLESTRIP的???序(2D 3D)
??的?序不是先??r??始的??
?楹芜@???例(2D/3D RPG角色扮演?? chapter06 Draw2D)是先以逆?r??始?
chapter06 Draw3D????例就是先以??r??始的.
附上Source Code
typedef struct {
FLOAT x, y, z; // 2-D coordinates
FLOAT rhw; // rhw
FLOAT u, v; // Texture coordinates
} sVertex;
#define VERTEXFVF (D3DFVF_XYZRHW | D3DFVF_TEX1)
BOOL DoInit()
{
D3DPRESENT_PARAMETERS d3dpp;
D3DDISPLAYMODE d3ddm;
BYTE *Ptr;
sVertex Verts[4] = {
{ 50.0f, 50.0f, 1.0f, 1.0f, 0.0f, 0.0f },
{ 350.0f, 50.0f, 1.0f, 1.0f, 1.0f, 0.0f },
{ 50.0f, 350.0f, 1.0f, 1.0f, 0.0f, 1.0f },
{ 350.0f, 350.0f, 1.0f, 1.0f, 1.0f, 1.0f }
};
......
}
BOOL DoFrame()
{
// Clear device backbuffer
g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, \
D3DCOLOR_RGBA(0,64,128,255), 1.0f, 0);
// Begin scene
if(SUCCEEDED(g_pD3DDevice->BeginScene())) {
// Set the vertex stream, shader, and texture
g_pD3DDevice->SetStreamSource(0, g_pVB, sizeof(sVertex));
g_pD3DDevice->SetVertexShader(VERTEXFVF);
g_pD3DDevice->SetTexture(0, g_pTexture);
// Draw the vertex buffer
g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
// Release texture
g_pD3DDevice->SetTexture(0, NULL);
// End the scene
g_pD3DDevice->EndScene();
}
// Display the scene
g_pD3DDevice-> resent(NULL, NULL, NULL, NULL);
return TRUE;
}
|
|