My Sprite is gone when i render the Skybox
Sorry Guys i feel so dumb today:)
I finally got the Sprite to render the right way.
Now i wanted to put it into my scene but its gone now.
all i do is render the skybox and then the sprite.
do i have to lock the z-buffer or something?
when i do it without the skybox it works just fine
i am doing this before i render the box
m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
and this after
m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
i can see other objects when i insert them just not the PointSprite
m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
and this after
m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
i can see other objects when i insert them just not the PointSprite
Quote:Original post by Rozik
i am doing this before i render the box
m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
and this after
m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
i can see other objects when i insert them just not the PointSprite
Try with:
m_pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
i tried that but that didnt help
it might be a diffrent problem though as i just found out something else.
when i put something other than 0 to the x or z position of the sprite it starts moving around which it really shouldnt
here is my code if anyone wants to take a look at it:
could it be something about the way i fill the Vertex-Buffer?
it might be a diffrent problem though as i just found out something else.
when i put something other than 0 to the x or z position of the sprite it starts moving around which it really shouldnt
here is my code if anyone wants to take a look at it:
struct PARTICLECUSTOMVERTEX{ float x, y, z; DWORD Diffuse;};#define D3DFVF_PARTICLEVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE)
class FBSParticleSystem{private:protected:public: FBSParticle *m_Particles; DWORD m_NumParticles; LPDIRECT3DVERTEXBUFFER9 m_pVB; LPDIRECT3DTEXTURE9 m_Texture; FBSParticleSystem(LPDIRECT3DDEVICE9 Device, DWORD NumParticles) { m_NumParticles = NumParticles; m_Particles = new FBSParticle[m_NumParticles]; m_pVB = NULL; m_Texture = NULL; Device->CreateVertexBuffer(m_NumParticles*sizeof(PARTICLECUSTOMVERTEX), 0, D3DFVF_PARTICLEVERTEX, D3DPOOL_DEFAULT, &m_pVB, NULL); if(FAILED(D3DXCreateTextureFromFile(Device, "Sprite.bmp", &m_Texture))){ MessageBox(NULL, "Could not find 2.bmp", "Particle", MB_OK); } } ~FBSParticleSystem() { if(m_pVB) m_pVB->Release(); if(m_Texture) m_Texture->Release(); if(m_Particles) delete [] m_Particles; } VOID Update(LPDIRECT3DDEVICE9 g_pd3dDevice) { PARTICLECUSTOMVERTEX *vertices = new PARTICLECUSTOMVERTEX[m_NumParticles]; for(DWORD Counter = 0; Counter < m_NumParticles; Counter++) { vertices[Counter].x = 5; vertices[Counter].y = 5; vertices[Counter].z = 0; } PARTICLECUSTOMVERTEX* pVertices = NULL; m_pVB->Lock( 0, sizeof(PARTICLECUSTOMVERTEX) * m_NumParticles, (void**)&pVertices, D3DLOCK_DISCARD); memcpy( pVertices, vertices, sizeof(PARTICLECUSTOMVERTEX)*m_NumParticles ); m_pVB->Unlock(); FLOAT MinSize, Scale1, Scale2, Scale3, Size; Size = 15.0f; MinSize = 0.0f; Scale1 = 0.0f; Scale2 = 0.0f; Scale3 = 1.0f; g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, false ); g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE); g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE); g_pd3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, true); g_pd3dDevice->SetRenderState(D3DRS_POINTSCALEENABLE, true); g_pd3dDevice->SetRenderState( D3DRS_POINTSIZE, *((DWORD*)&Size )); g_pd3dDevice->SetRenderState(D3DRS_POINTSIZE_MIN, *((DWORD*)&MinSize)); g_pd3dDevice->SetRenderState(D3DRS_POINTSCALE_A, *((DWORD*)&Scale1)); g_pd3dDevice->SetRenderState(D3DRS_POINTSCALE_B, *((DWORD*)&Scale2)); g_pd3dDevice->SetRenderState(D3DRS_POINTSCALE_C, *((DWORD*)&Scale3)); g_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(PARTICLECUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_PARTICLEVERTEX ); g_pd3dDevice->SetTexture(0, m_Texture); g_pd3dDevice->DrawPrimitive( D3DPT_POINTLIST, 0, m_NumParticles ); g_pd3dDevice->SetRenderState( D3DRS_POINTSCALEENABLE, FALSE ); g_pd3dDevice->SetRenderState( D3DRS_POINTSPRITEENABLE, FALSE ); g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,false); }};
could it be something about the way i fill the Vertex-Buffer?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement