Original Post
Hi, I'm currently trying to draw some point sprites but I seem to be having a problem. This is the relevant code: The point sprite isn't being rendered but 1 pixel directly in the middle of the screen is lit up so I assume something is happening. Can anyone spot where I am going wrong?
// Vertex format and particle structure
struct SParticleVertex
{
D3DXVECTOR3 m_Position;
enum FVF
{
FVF_Flags = D3DFVF_XYZ|D3DFVF_DIFFUSE
};
};
struct SParticle
{
D3DXVECTOR3 m_Position;
};
const int MAX_PARTICLES = 2;
SParticle g_particles[MAX_PARTICLES];
LPDIRECT3DVERTEXBUFFER9 VertexBuffer = NULL;
LPDIRECT3DTEXTURE9 smokeTex;
// Vertex buffer creation and point sprite setup
D3DXCreateTextureFromFile( d3dManager->m_d3dDevice, "Smoke1.tga", &smokeTex );
d3dManager->m_d3dDevice->CreateVertexBuffer( MAX_PARTICLES * sizeof(SParticleVertex),
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY | D3DUSAGE_POINTS,
SParticleVertex::FVF_Flags, D3DPOOL_DEFAULT,
&VertexBuffer, NULL );
for( int i = 0; i < MAX_PARTICLES; ++i )
{
g_particles.m_Position = D3DXVECTOR3(0.0f,i,0.0f);
}
d3dManager->m_d3dDevice->SetRenderState( D3DRS_POINTSPRITEENABLE, TRUE );
d3dManager->m_d3dDevice->SetRenderState( D3DRS_POINTSCALEENABLE, TRUE );
// Render point list
SParticleVertex *pPointVertices;
VertexBuffer->Lock( 0, MAX_PARTICLES * sizeof(SParticleVertex),
(void**)&pPointVertices, D3DLOCK_DISCARD );
for( int i = 0; i < MAX_PARTICLES; ++i )
{
pPointVertices->m_Position = g_particles.m_Position;
pPointVertices++;
}
VertexBuffer->Unlock();
CRenderMethod* method = Renderer->GetMethod( Texture );
d3dManager->m_d3dDevice->SetVertexShader( method->m_vs->m_Shader );
d3dManager->m_d3dDevice->SetPixelShader( method->m_ps->m_Shader );
d3dManager->m_d3dDevice->SetTexture( 0, smokeTex );
d3dManager->m_d3dDevice->SetStreamSource( 0, VertexBuffer, 0, sizeof(SParticleVertex) );
d3dManager->m_d3dDevice->SetFVF( SParticleVertex::FVF_Flags );
d3dManager->m_d3dDevice->DrawPrimitive( D3DPT_POINTLIST, 0, MAX_PARTICLES );