Sign in to follow this  
joachim_n

Problem: Pointsprites are just black [D3D9]

Recommended Posts

Hi, I have a small problem and now I'm just confused. As the topic already points out, I tried working with point sprites and my problem is that they appear as black quads which are not alpha blended on my 8800GT. Scaling however works. Here is the code that I use to do the rendering:
void PointSpriteCloud::render (unsigned howmuch)
{
	float pointsize = 1.0f;
	float parama = 1.0;
	float paramb = 1.5;
	float paramc = 0.0;

	m_device->SetRenderState (D3DRS_ZWRITEENABLE, FALSE);

	m_device->SetRenderState (D3DRS_ALPHABLENDENABLE, TRUE);
	m_device->SetRenderState (D3DRS_SRCBLEND, GL_ONE);
	m_device->SetRenderState (D3DRS_DESTBLEND, GL_ONE);

	HRESULT hr = m_device->SetRenderState (D3DRS_POINTSPRITEENABLE, TRUE);
	
	if (FAILED (hr)) {
		throw Exception ("D3DException", "PointSpriteCloud::render", "SetRenderState failed.\n");
	}

	m_device->SetRenderState (D3DRS_POINTSCALEENABLE, TRUE);

	m_device->SetRenderState (D3DRS_POINTSIZE, *(DWORD*)&pointsize);
	m_device->SetRenderState (D3DRS_POINTSIZE_MIN, *(DWORD*)&pointsize);
	m_device->SetRenderState (D3DRS_POINTSCALE_A, *(DWORD*)¶ma);
	m_device->SetRenderState (D3DRS_POINTSCALE_B, *(DWORD*)¶mb);
	m_device->SetRenderState (D3DRS_POINTSCALE_C, *(DWORD*)¶mc);

	m_texture->bind ();

	m_device->SetStreamSource (0, m_buffer, 0, sizeof (XYZCOL));
	m_device->SetFVF (D3DFVF_XYZ|D3DFVF_DIFFUSE);
	
	hr = m_device->DrawPrimitive (D3DPT_POINTLIST, 0, howmuch);
	if (FAILED (hr)) {
		throw Exception ("RenderException", "PointSpriteCloud::render", "DrawPrimitive failed.\n");
	}

	m_texture->unbind ();
	m_device->SetRenderState (D3DRS_POINTSPRITEENABLE, FALSE);
	m_device->SetRenderState (D3DRS_POINTSCALEENABLE, FALSE);

	m_device->SetRenderState (D3DRS_ALPHABLENDENABLE, FALSE);
	m_device->SetRenderState (D3DRS_ZWRITEENABLE, TRUE);
}
m_texturs's type is my texture class, which works well for 3d Models. Well, I tried googling for a problem like this, I compared my code to an example that works and didn't find anything. PIX doesn't produce any debug messages. I guess it'll be something truely simple that I've done wrong, but I just can't find it. Thanks for reading. ^^

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this