Particle Engine

Hi
I Make a Particle Engine.
But i have a tiny problem.

if i draw particles befor draw teapot , always paricles are seen back of the teapot.

SMOKE_INIT[1].Make_Smoke();
FIRE_INIT[1].Make_Fire();
FIRE_JET_INIT[1].Make_Jet();
WATER_JET_INIT[1].Make_Jet();
RAIN_INIT.Make_Rain();
glTranslatef(0,0.35,-0.5);
glColor4f(0.7,0.4,0.1,1);
glutSolidTeapot(0.5);

and if i draw teapot befor draw particles , always teapot are seen back of the paricles.

glTranslatef(0,0.35,-0.5);
glColor4f(0.7,0.4,0.1,1);
glutSolidTeapot(0.5);
SMOKE_INIT[1].Make_Smoke();
FIRE_INIT[1].Make_Fire();
FIRE_JET_INIT[1].Make_Jet();
WATER_JET_INIT[1].Make_Jet();
RAIN_INIT.Make_Rain();

i write this code befor draw each Particles :

glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND|GL_ALPHA_TEST);
glBlendFunc(GL_SRC_ALPHA,GL_DST_ALPHA);

i know that this problem is result of disabling depth test…
plaese help me about this problem.
:confused:
draw_particles_befor_draw_teapot.zip
draw_teapot_befor_draw_particles.zip
draw_particles_with_depthtest.zip

Hold on a second. Let me get this straight…

The particles are in back of the teapot? Or the teapot is in back of the particles?

Not to nitpick but your blend enable looks like its got a bad case of Orlicula Pipitis. And your blend func may not work as you expect, especially without a destination alpha channel.

I had said that if i draw particles befor teapot , always paricles are seen back of the teapot and if i draw teapot befor particles , always teapot is seen back of the paricles.
I know that this problem is result of disabling depth test but without disabling depth , the particles had seen very bad.
i test every blend func but don’t right
i upload my files again in an other site.
please see my files, then answer me.
thank u.
draw_teapot_befor_draw_particles
draw_particles_befor_draw_teapot
draw_particles_with_depthtest

without disabling depth , the particles had seen very bad.

Enable depth correctly to draw the teapot. Then disable depth writes (keep depth test), and draw the particles.

I had done this work…
I after draw each particle ,enable depth test.

I after draw each particle ,enable depth test.

I don’t think you understood exactly. Without seeing your code it’s difficult to verify, but it seems you should be doing:


// Draw teapot
glEnable( GL_DEPTH_TEST );
glDepthMask( GL_FALSE ); // Enable depth writes
glutSolidTeapot(0.5);

// Draw particles
glDepthMask( GL_FALSE ); // Disable depth writes
glEnable(GL_BLEND|GL_ALPHA_TEST);
glBlendFunc(GL_SRC_ALPHA,GL_DST_ALPHA);
SMOKE_INIT[1].Make_Smoke();
FIRE_INIT[1].Make_Fire();
FIRE_JET_INIT[1].Make_Jet();
WATER_JET_INIT[1].Make_Jet();
RAIN_INIT.Make_Rain();

very very very … thanks,I write this:
glDepthMask( GL_FALSE );
// Draw particles
glDepthMask( GL_TRUE );
and working very well now… :wink:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.