|
|

楼主 |
发表于 2005-8-24 10:36:00
|
显示全部楼层
Re:Mesh和画矩形的问题
HRESULT CGeometry9: rawFilledRect(float x1, float y1, float x2, float y2)
{
VERTEX2D* pVertices;
if( FAILED( m_pVBRect->Lock( 0, sizeof(VERTEX2D)*4, (VOID**)&pVertices, 0 ) ) )
return E_FAIL;
pVertices[0] = VERTEX2D( x1, y1, m_d3dColor );
pVertices[1] = VERTEX2D( x2, y1, m_d3dColor );
pVertices[2] = VERTEX2D( x1, y2, m_d3dColor );
pVertices[3] = VERTEX2D( x2, y2, m_d3dColor );
m_pVBRect->Unlock();
//使用索引缓存
VOID* pIndices;
static WORD wIndices[] = {0, 1, 2, 3, 2, 1};
if( FAILED( m_pIBRect->Lock( 0, sizeof(wIndices), (VOID**)&pIndices, 0 ) ) )
return E_FAIL;
memcpy( pIndices, wIndices, sizeof(wIndices) );
m_pIBRect->Unlock();
m_pd3dDevice->SetFVF( D3DFVF_VERTEX2D );
m_pd3dDevice->SetStreamSource( 0, m_pVBRect, 0, sizeof(VERTEX2D) );
m_pd3dDevice->SetIndices( m_pIBRect );
m_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,
0,
0,
4, // 顶点数
0,
2); // 两个三角列
return S_OK;
} |
|