|
|

楼主 |
发表于 2006-12-29 16:26:00
|
显示全部楼层
Re:请教DrawIndexedPrimitive参数问题
下面是我的部分代码
IDirect3DVertexBuffer9 *pVertexBuffer;
PVERTEX pVertex;
m_lpD3DDevice9->CreateVertexBuffer(4*sizeof(VERTEX),0,m_dwFVF,D3DPOOL_DEFAULT,&pVertexBuffer,NULL);
pVertexBuffer->Lock(0,0,(LPVOID*)&pVertex,0);
ZeroMemory(&pVertex[0],sizeof(VERTEX));
ZeroMemory(&pVertex[1],sizeof(VERTEX));
ZeroMemory(&pVertex[2],sizeof(VERTEX));
ZeroMemory(&pVertex[3],sizeof(VERTEX));
pVertex[0].x = 200;
pVertex[0].y = 200;
pVertex[0].diffuse = D3DCOLOR_ARGB(255,255,0,0);
pVertex[1].x = 400;
pVertex[1].y = 200;
pVertex[1].diffuse = D3DCOLOR_ARGB(255,0,255,0);
pVertex[2].x = 300;
pVertex[2].y = 370;
pVertex[2].diffuse = D3DCOLOR_ARGB(255,0,0,255);
pVertex[3].x = 200;
pVertex[3].y = 200;
pVertex[3].diffuse = D3DCOLOR_ARGB(255,0,0,255);
pVertexBuffer->Unlock();
m_lpD3DDevice9->SetStreamSource(0,pVertexBuffer,0,sizeof(VERTEX));
IDirect3DIndexBuffer9 *pIndexBuffer;
LPWORD pIndex;
m_lpD3DDevice9->CreateIndexBuffer(6*sizeof(WORD),0,D3DFMT_INDEX16,D3DPOOL_DEFAULT,&pIndexBuffer,NULL);
pIndexBuffer->Lock(0,0,(LPVOID*)&pIndex,0);
pIndex[0] = 0;
pIndex[1] = 1;
pIndex[2] = 0;
pIndex[3] = 2;
pIndex[4] = 1;
pIndex[5] = 2;
pIndexBuffer->Unlock();
m_lpD3DDevice9->SetIndices(pIndexBuffer);
m_lpD3DDevice9->DrawIndexedPrimitive(D3DPT_LINELIST,0,10000,1111,0,3);
pVertexBuffer->Release();
pIndexBuffer->Release(); |
|