float alpha=1.0f-(((float)frame)/50.0f); //This creates an alpha value depending on the frame that is being rendered (ie the higher the frame, the more transparent the object is.
glBlendFunc (GL_SRC_COLOR, GL_SRC_ALPHA); //I have tried many combinations.
glColor4f(1.0f, 1.0f, 1.0f, alpha);
model->drawModel();
Fading out an object.
Hey, Sorry if this is a really common question but I have searched high and low and not found a solution. I am trying to make an object (ASE loaded and rendered as GL_TRIANGLES) fade out slowly. The object has a texture mapped to it and this is handled properly in a drawModel() function that I use. Here is the code I'm using. Note that frame is always -1 < frame < 51 For all frames up to 49 (or around 49 (I haven't verified this)) the object appears solid, then, suddenly, it disappears. How can I fix this and make it a gradual fade. Note - using SDL Thanks Connell
This doesn't work unfortunately - the object doesn't appear at all (at any time). I have worked out that for some values in glBlendFunc, the alpha value makes no difference, for others, I start with a partially transparent object which fades out, and finally in some the object is completely transparent.
Aarrg!!
Aarrg!!
I might be missing something here (eminently possible ;) ) but could you not just use 'glColor3f(alpha, alpha, alpha)' ?
--
Cheers,
Darren Clark
Cheers,
Darren Clark
That wouldn't work because, you are taking the color and fading it from white to black as alpha goes from 1 to 0. If the texture(I think it is MODULATE) is under a certain type(unclear on which one) the texture is affected by the color that is used. If you had only a black background, this would work, but you probably don't so use GL_BLEND instead as above shown.
for (float i = 1.0; i >= 0.0; i-=0.1){ glColor4f(i, i, i, alpha); drawStuffHere;}glColor4f(1.0f, 1.0f, 1.0f, alpha); //So everything else's color is normal still.
"My Knowledge Has Served Me Right. Unless It Is Serving Me Wrong".
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement