Jump to content
  • Advertisement
Sign in to follow this  
Rozik

My Sprite is gone when i render the Skybox

This topic is 4483 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

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

Share this post


Link to post
Share on other sites
Advertisement
Turn off ZWrite when rendering the skybox, or clear the Z-buffer after rendering the skybox.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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:


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?

Share this post


Link to post
Share on other sites
tried it but doesnt help:)

i really think its a general problem with the rendering of the sprite

it really shouldnt move when i set the position to a constant spot:)

i just cant figure out the error:(

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!