   Point sprites taken too literally
  Hi,I'm implementing a point-sprite-based particle system into my 3D FPS, and using code samples from a CodeSampler example which works fine on this machine, showing all the textures visibly scaled to distance. When I try it in my engine, however, they all show up as only a single white pixel. Here's my relevant code:Defs and VB:#define PARTIKELFVF (D3DFVF_XYZ|D3DFVF_DIFFUSE)struct PARTIKELVERTEX{D3DXVECTOR3 pos;D3DCOLOR color;};struct partikel_s{    D3DXVECTOR2 pos,vel; //Current position/velocity of particle    INT land;//what piece of land it's on    INT shooter;//Who shot it    partikel_s *last,*next; //doubly-linked list};LPDIRECT3DVERTEXBUFFER9 partikelVB;graphDevice->CreateVertexBuffer(NUM_ZU_DISCARD*sizeof(PARTIKELVERTEX),    D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY|D3DUSAGE_POINTS,    PARTIKELFVF,    D3DPOOL_DEFAULT,    &partikelVB,    NULL);States (the sample used FtoDW() on some float values corresponding to these; I just changed them to the integer values directly):graphDevice->SetVertexShader(NULL);graphDevice->SetPixelShader(NULL);graphDevice->SetTexture(0,image[PARTIKEL_IMAGE_INDEX]);//Setting D3DRS_ZWRITEENABLE to FALSE makes the Z-Buffer read-only,//which helps remove graphical artifacts generated from rendering a list of// particles that haven't been sorted by distance to the eye.graphDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);//Setting D3DRS_ALPHABLENDENABLE to TRUE allows particles, which overlap,//to alpha blend with each other correctly.g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);graphDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);graphDevice->SetRenderState(D3DRS_POINTSPRITEENABLE,TRUE);//Turn on point sprites//Allow sprites to be scaled with distancegraphDevice->SetRenderState(D3DRS_POINTSCALEENABLE,TRUE);//Specifies the size to use for point size computation//in cases where point size is not specified for each vertex.graphDevice->SetRenderState(D3DRS_POINTSIZE,1);//Specifies the minimum size of point primitives.//Point primitives are clamped to this size during rendering.graphDevice->SetRenderState(D3DRS_POINTSIZE_MIN,1);graphDevice->SetRenderState(D3DRS_POINTSCALE_A,0);//Default 1.0//graphDevice->SetRenderState(D3DRS_POINTSCALE_B,0);//Default 0.0graphDevice->SetRenderState(D3DRS_POINTSCALE_C,1);//Default 0.0Drawing:HRESULT hr;D3DXVECTOR3 vPos;DWORD numParticlesToRender=0;partikel_s *part;PARTIKELVERTEX *pVerts;static INT offset=0;//Move the offset forward so we can fill the next chunk of the vertex buffer.//If we're about to overflow the buffer, reset the offset counter back to 0if((offset+=NUM_ZU_FLUSH)>=NUM_ZU_DISCARD)offset=0;//Lock the vertex buffer. We fill the vertex buffer in small chunks, using D3DLOCK_NOOVERWRITE.if(FAILED(hr=partikelVB->Lock(offset*sizeof(PARTIKELVERTEX),NUM_ZU_FLUSH*sizeof(PARTIKELVERTEX),    (void**)&pVerts,offset?D3DLOCK_NOOVERWRITE:D3DLOCK_DISCARD)))return hr;for(part=g_firstParticle;part;part=part->naechst){//Render each particle in the linked listpVerts->pos=landWeltKoord(part->land,part->pos.x,part->pos.y);   pVerts->color=D3DXCOLOR(1.0f,1.0f,1.0f,1.0f);   pVerts++;   if(++numParticlesToRender==NUM_ZU_FLUSH){  //Here we would unlock the buffer, draw what we have, and lock again.  //this is only for when there are huge numbers of particles to draw,   //which hasn't happened yet.  numParticlesToRender=0;   }    }    partikelVB->Unlock();//Unlock the vertex buffer    if(numParticlesToRender){//Render any remaining particles (this is generally what draws in my case)graphDevice->SetStreamSource(0,partikelVB,0,sizeof(PARTIKELVERTEX));graphDevice->SetFVF(PARTIKELFVF);   if(FAILED(hr=graphDevice->DrawPrimitive(D3DPT_POINTLIST,offset,numParticlesToRender)))return hr;    }I have tried playing with the sizes (ie. D3DRS_POINTSIZE, D3DRS_POINTSIZE_MIN, etc. to 32 or 64) with no difference in effect.I'm using DirectX 9.0c SDK on VC++ Express 2008 in Windows XP on an Inspiron E1505 with on-board i945g graphics card.Help appreciated, thanks.   
  For posterity, it was fixed by indeed passing FtoDW()'ized arguments to the SetRenderState calls. It works, albeit I still don't why there's a difference between:*((DWORD*)&(1.0f))and:(DWORD)1;Quote:Original post by bababooeyFor posterity, it was fixed by indeed passing FtoDW()'ized arguments to the SetRenderState calls. It works, albeit I still don't why there's a difference between:*((DWORD*)&(1.0f))and:(DWORD)1First, I'm surprised that your compiler would let you take the address of a literal.  Normally that shouldn't work.Next, the bit pattern for the value 1 is not the same as the bit pattern for floating point 1.0f;dword float0x1   1.401e-045#DEN0x3f800000 1.0fBut, casting (DWORD)1.0f  has the compiler do a real value cast in order to get the value 0x1.   