Archived

This topic is now archived and is closed to further replies.

Arion

Program aborts on particle effect

Recommended Posts

Very strange problem here. I have a particle system which works fine in a very mysterious circumstance. I have two classes, one for rain, the other for a particle effect. If I do this: Draw Rain Draw particles It works fine. But when I take the rain drawing routine out, the program aborts. The rain drawing routine:
        
void C_Rain::Draw_Rain()
{
  Update_Rain();
  
  g_pd3dDevice -> SetRenderState( D3DRS_LIGHTING, FALSE );
  g_pd3dDevice -> SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT );
  // setup to draw

  g_pd3dDevice -> SetStreamSource( 0, Rain_VB, sizeof( S_Rain ) );
  g_pd3dDevice -> SetVertexShader( D3DFVF_Rain_Flag );
           
  
  // REMMING THIS LINE CAUSES PROGRAM ABORT

  g_pd3dDevice -> DrawPrimitive( D3DPT_LINELIST, 0, NUM_DROPS );
  
}// end Draw_Rain

  
_________________________________________________ The firefly ( particle system drawing routine):
    
void C_FireFly::Draw()
{
  // setup and draw the particle poles

  g_pd3dDevice -> SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
  g_pd3dDevice -> SetRenderState( D3DRS_POINTSPRITEENABLE, TRUE );
  g_pd3dDevice -> SetRenderState( D3DRS_POINTSCALEENABLE,  TRUE );
  g_pd3dDevice -> SetRenderState( D3DRS_POINTSIZE, FtoDW(0.0025f) );
  
  g_pd3dDevice -> SetVertexShader( D3DFVF_XYZDIFFUSE );
  g_pd3dDevice -> SetStreamSource( 0, FireFly_VB, sizeof( S_XYZDIFFUSE ) );
  g_pd3dDevice -> DrawPrimitive( D3DPT_POINTLIST, 0, 1000 );
  
  g_pd3dDevice -> SetRenderState( D3DRS_POINTSCALEENABLE,  FALSE );
  g_pd3dDevice -> SetRenderState( D3DRS_POINTSPRITEENABLE, FALSE );
  g_pd3dDevice -> SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
  
Update();

}// end Draw

  
Note remming out the DrawPrimitive function is all I have to do to cause a program abort. Leaving it in, it draws the rain and particles just fine. [EDIT] Edited for clarity. [/EDIT] Guy, I regress: WW, TTC, THTV. [edited by - Arion on October 17, 2002 3:52:02 PM]

Share this post


Link to post
Share on other sites

An interesting developement.

I find that if I call the rain drawing routine only once in the render loop, the program runs fine and does not abort. The particles are drawn just fine.

I wonder if there is something wrong with the Direct X files.
Lots of ! beside many file names in the Direct X diagnostic utility. Doesn''t look too good.


Guy, I regress: WW, TTC, THTV.

Share this post


Link to post
Share on other sites
My money is on a memory bug.

The problem has already occured, try excluding/changing code/classes executed before the particle and rain classes.

D.V.

Carpe Diem

Share this post


Link to post
Share on other sites
No such luck I''m afraid.
Thanks for the suggestion DeltaVee.

I did all the above and the program still aborts unelss the DrawPrimitive function with the rain is still there.


Guy, I regress: WW, TTC, THTV.

Share this post


Link to post
Share on other sites

Definitely corrupting memory in a major way.

When I get the error, all my other projects won''t run. I two different compilers Visual C++ and Dev C++.

It takes a reboot to sort things out.
I''m going to have to stop playing with the dumb thing.
Many reboots == real pain in the you know what

I also re-installed Direct X 8.0 just in case there was something wrong with that.

Guy, I regress: WW, TTC, THTV.

Share this post


Link to post
Share on other sites