I was trying to implement a particle system using PointSprites. Draw calls return D3D_OK but I don't see any particle on the screen. I'm not using Vertex Buffer for the particles, but I use two vectors of vertices and I call the DrawPrimitiveUP function. This is my code:
CreatePntVertices();
pD3DD -> SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pD3DD -> SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pD3DD -> SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
pD3DD -> SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
pD3DD -> SetRenderState(D3DRS_ZENABLE, FALSE);
pD3DD -> SetRenderState(D3DRS_LIGHTING, FALSE);
pD3DD -> SetFVF(FVF_PNTVERTEX);
pD3DD -> SetTexture(0, pTex[TEX_POINT]);
pD3DD -> SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
pD3DD -> SetRenderState(D3DRS_POINTSCALEENABLE, TRUE);
pD3DD -> SetRenderState(D3DRS_POINTSCALE_A, 0.0f);
pD3DD -> SetRenderState(D3DRS_POINTSCALE_B, 0.0f);
pD3DD -> SetRenderState(D3DRS_POINTSCALE_C, 1.0f);
pD3DD -> SetRenderState(D3DRS_POINTSIZE, 20.0f);
pD3DD -> SetRenderState(D3DRS_POINTSIZE_MIN, 3.0f);
pD3DD -> SetRenderState(D3DRS_POINTSIZE_MAX, 50.0f);
D3DXMatrixIdentity(&mWorld);
pD3DD -> SetTransform(D3DTS_WORLD, &mWorld);
pD3DD -> DrawPrimitiveUP(D3DPT_POINTLIST, pntPlanets.size(), (PVOID)pntPlanets.data(), sizeof(PNTVERTEX));
pD3DD -> SetRenderState(D3DRS_POINTSIZE, 40.0f);
pD3DD -> SetRenderState(D3DRS_POINTSIZE_MIN, 9.0f);
pD3DD -> SetRenderState(D3DRS_POINTSIZE_MAX, 70.0f);
pD3DD -> DrawPrimitiveUP(D3DPT_POINTLIST, pntStars.size(), (PVOID)pntStars.data(), sizeof(PNTVERTEX));
pD3DD -> SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
pD3DD -> SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
pD3DD -> SetRenderState(D3DRS_POINTSPRITEENABLE, FALSE);
pD3DD -> SetRenderState(D3DRS_POINTSCALEENABLE, FALSE);
CreatePntVertices()
is a function that set the position of objects and their color into two vectors of PNTVERTEX
(pntStars
and pntPlanets
). pTex
is an array of textures. mWorld
is a D3DXMATRIX
. pD3DD
is the Device. FVF_PNTVERTEX
is set as (D3DFVF_XYZ | D3DFVF_DIFFUSE)
. I really don't know why it doesn't work, I tried everything to make it work. Maybe, should I use a dynamic vertex buffer instead?
D3DCAPS9.MaxPointSize
has to be something other than 1.0 or 0.0. See MSDN. \$\endgroup\$