|
|
我想画一组点精灵到屏幕上,奇怪的是只显示了第一个point,别的都不显示,部分代码如下:
struct PointVertex
{
D3DXVECTOR3 pos;
D3DCOLOR color;
static const DWORD FVF;
};
const DWORD PointVertex::FVF = D3DFVF_XYZ| D3DFVF_DIFFUSE;
struct Particle
{
D3DXVECTOR3 m_vCurPos;
D3DCOLOR m_dwColor;
//other attirbute omit..
};
hr = pd3dDevice->CreateVertexBuffer(
m_dwMaxParticles * sizeof(PointVertex),
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY | D3DUSAGE_POINTS,
PointVertex::FVF,
D3DPOOL_DEFAULT,
&m_pVB, NULL );
Particle *pParticle = m_pActiveList;
PointVertex *pVertices;
m_pVB->Lock(0,0,(void **)&pVertices,0);
while(pParticle)
{
pVertices->pos = pParticle->m_vCurPos;
pVertices->color = pParticle->m_dwColor;
pParticle = pParticle->m_pNext;
}
m_pVB->Unlock();
pd3dDevice->SetTexture(0, m_ptexParticle);
pd3dDevice->SetFVF( PointVertex::FVF );
pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(PointVertex) );
pd3dDevice->DrawPrimitive( D3DPT_POINTLIST, 0,20); |
|