Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

fei

Point Sprite

This topic is 5356 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can I make point sprite for a particle? What should I set up for that?

Share this post


Link to post
Share on other sites
Advertisement
You''ll have to tell d3d that you''re using point sprites first by setting the FVF. The you''ll have o make a structure for you''re point sprites. The you have to create teh vertex buffer with the D3DUSAGE_POINTSPRITE (or something similar) flag. Then you do everything else as normal. There are a few renderstates you can use to control the point sprites'' sizes. but yu can also do that from within your custom structure. Also dosnt forget to check the point sprite sample that comes with the SDK.


:::: [ Triple Buffer V2.0 ] ::::

Share this post


Link to post
Share on other sites
I just tried, but I found something wrong. When I run & exe, there was nothing in screen, just blank.
The code :

// structure for my custom vertex type
struct CUSTOMVERTEX
{
FLOAT x,y,z;
DWORD color;
float pointsize;
};

// create the vertex buffer for one vertex
g_pd3dDevice->CreateVertexBuffer(1*sizeof(CUSTOMVERTEX), D3DUSAGE_WRITEONLY|D3DUSAGE_POINTS, MYCUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB);

// fill the vertex buffer
CUSTOMVERTEX* pVertices;
if (FAILED(g_pVB->Lock(0,sizeof(Vertices),(BYTE**)&pVertices,0)))
return E_FAIL;
memcpy(pVertices,Vertices,sizeof(Vertices));
g_pVB->Unlock();

// Set the render states for using point sprites
g_pd3dDevice->SetRenderState( D3DRS_POINTSPRITEENABLE, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_POINTSCALEENABLE, TRUE );

Have I missed something ? Thanks again for any helps ...

Share this post


Link to post
Share on other sites
There are a few other render states that you can mess around with for point sprites. also as mentioned above, lighting should be off

m_pD3DDevice->SetRenderState(D3DRS_POINTSIZE, ? );
m_pD3DDevice->SetRenderState(D3DRS_POINTSIZE_MIN, ?);
m_pD3DDevice->SetRenderState(D3DRS_POINTSIZE_MAX, ?);
m_pD3DDevice->SetRenderState(D3DRS_POINTSCALE_A, ?);
m_pD3DDevice->SetRenderState(D3DRS_POINTSCALE_B, ?);
m_pD3DDevice->SetRenderState(D3DRS_POINTSCALE_C, ?);

and are you creating a vertex buffer for ONE point deliberately or is that a mistake? Also the renderstates that are POINTSCALE_A/B/C are like the attenuation properties of a light structure (attenuation0/1/2).


:::: [ Triple Buffer V2.0 ] ::::

Share this post


Link to post
Share on other sites
Your custom vertex data is in the wrong order. The FFP is expecting size as the second parameter in the structure and color as the third.

Since you''re using per-vertex data, you don''t want to call SetRenderState(D3DRS_POINTSIZE, Data);

Also, these render states require DWORDS, but you pass in floats.

float Data = 1.0f;

m_pD3DDevice->SetRenderState(D3DRS_POINTSCALE_C, *((DWORD*)&Data));

Chris

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!