PDA

View Full Version : Sprite points and gl blending



TuTToWeB
06-14-2010, 10:16 AM
Hi guys,
I made a particle system from scratch and I've got some problem with blending.
This is my code


void BeforeDrawingFire(ParticleSystem* ps)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

GLfloat sizes[2];
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE,sizes);

glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D, VolcanoFireSprite.glutId);


glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 10.0f );
glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, sizes[1] );
glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);

glDisable( GL_DEPTH_TEST );
//glDepthMask(GL_FALSE);

glPointSize(32.0f);

glEnable(GL_POINT_SPRITE_ARB);

float quadratic[] = { 1.0f, 5.0f, 10.0f };
glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic );
glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f );

glPushMatrix();


}

void VolcanoFountainParticle(Particle* p)
{
glBegin(GL_POINTS);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(p->Position.x,p->Position.y,p->Position.z);
glEnd();
}

void AfterDrawingFire(ParticleSystem* ps)
{
glPopMatrix();
glEnable( GL_DEPTH_TEST );
glDisable(GL_BLEND);
glDisable( GL_TEXTURE_2D );
glDisable(GL_POINT_SPRITE_ARB);
//glDepthMask(GL_TRUE);
}



It works in this way: my particle system engine calls
BeforeDrawingFire, then calls (for EACH PARTICLE) VolcanoFountainParticle. At the end of the drawing, it calls AfterDrawingFire.
The problem is it should drawing the particle with the color I set with glColor4d, but it continues to keep the original one...
This is my sprite: https://galileo.dmi.unict.it/svn/cgassignment/q4/pictures/particle.bmp

Because of the blending, it should be red (glColor3f(1.0f,0.0f,0.0f); ), but it doesnt.
What did I forget?
Thank you so much

strattonbrazil
06-14-2010, 04:18 PM
What's the texture environment set to? GL_GLENDING is for blending what's going down to what's already there. You might need to setup the texture to multiply against glColor. See the docs for glTexEnv. You probably want GL_MODULATE.