Problem: Pointsprites are just black [D3D9]

Started by
-1 comments, last by joachim_n 15 years, 6 months ago
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*)&parama);
	m_device->SetRenderState (D3DRS_POINTSCALE_B, *(DWORD*)&paramb);
	m_device->SetRenderState (D3DRS_POINTSCALE_C, *(DWORD*)&paramc);

	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. ^^

This topic is closed to new replies.

Advertisement