开发者

Using point sprites with direct x. what steps need to be taken?

This is still an outstanding issue.

I am trying to get a point sprites system workign render a sun in my world. I noticed another user asking a similar question (with the same code, presumably from my class :) ) but they were not able to complete this. My current code for this is as follows:

 float fPointSize = 10.0f,fPointScaleB = 100.0f;

IDirect3DDevice9 *m_Device = LudoRenderer::GetInstance()->GetDevice(); m_Device->SetRenderState(D3DRS_POINTSPRITEENABLE,true); m_Device->SetRenderState(D3DRS_POINTSCALEENABLE,true);

 m_De开发者_如何学运维vice->SetRenderState(D3DRS_POINTSIZE,
                                  *((DWORD*)&fPointSize));
    m_Device->SetRenderState(D3DRS_POINTSCALE_B,
                                  *((DWORD*)&fPointScaleB));

    m_Device->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
    m_Device->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ONE);
    m_Device->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);


    std::wstring hardcoded = L"..\\Data\\sun.png";
 m_SunTexture = LudoTextureManager::GetInstance()->GetTextureData(hardcoded.c_str()).m_Texture;

  m_Device->SetTexture(0,m_SunTexture);
     m_Device->DrawPrimitive(D3DPT_POINTLIST,0,12);

I do not see my sun on the screen, and it seems to be doing the alpha blend on the rest of my world, rather than on any sun I'm trying to load. Could this be because of which devices I'm using? Any help would be greatly appreciated :)


You don't actually seem to have a draw call in there. Have you missed posting some code, or is this perhaps your problem?

If you're missing the draw call, I would suggest the DrawPrimitiveUP() call is likely the one you want. You'll also need to set the stream format to match your vetex structure ( setFVF() ). Something along these lines:

#define D3DFVF_SUNVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)

struct SUNVERTEX
{
  float x,y,z;
  DWORD colour;
};

D3DVECTOR pos = { 0.f, 0.f, 0.f }; // Set this to the position you want
SUNVERTEX sunVert = { pos.x, pos.y, pos.z, D3DCOLOR_RGBA( 255, 255, 0, 255 ) };

IDirect3DDevice9& device = LudoRenderer::GetInstance()->GetDevice();
device->SetFVF( D3DFVF_SUNVERTEX );
device->DrawPrimitiveUP( D3DPT_POINTLIST, 1, sunVert, sizeof(SUNVERTEX) );

If you have time I'd strongly recommend reading the "Programming Guide" from the DirectX SDK documentation (you should have it installed). It's not much of a tutorial, but it does cover the basics of DirectX architecture.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜