Archived

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

Fading in/out of a scene

This topic is 5844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im currently making a demo, but Im having a lot of trouble getting it to fade in/out of black. Ive tried giving the whole scene an alpha value and slowly increasing that ... but it just appears like normal. Ive tried blending a black quad over the entire scene and changing its alpha value and still no luck. Anyone care to enlighten me as to what im doing wrong... I am probably not blending the quad properly or somthing like that. Thanks in advance... i can post some of the code if need be

Share this post


Link to post
Share on other sites
One option (not the best) is to use the imaging extention. It has a brightness control. But stay away from extentions whenever possible. I have always used the black quad like you said, it should by all means work. Show some code and I may be able to spot your problem.

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


Link to post
Share on other sites
	
if (morphin == true)
{
glLoadIdentity();
glTranslatef(0,0,-10);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glEnable(GL_BLEND); // Enable Blending
glColor4f(0,0,0,morphval);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glBegin(GL_QUADS);
glVertex3f(-500,500,0);
glVertex3f(500,500,0);
glVertex3f(500,-500,0);
glVertex3f(-500,-500,0);
glEnd();
morphval -= 0.01f;
if(morphval <= 0)
{
morphin = false;
}
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
}


Thats what I have now... I tried a bunch of other ways... like without disabling lighting and depth testing ... but that did nothing...

Thanks again

Share this post


Link to post
Share on other sites
First off, I assume this is being called at the end of the draw code, as it disables depth testing. Second, try using

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Um, I think that''s right. Lemme know.

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


Link to post
Share on other sites
For a black quad, you can use GL_ZERO, GL_ONE_MINUS_SRC_ALPHA or even GL_ONE, GL_SRC_ALPHA (and then think of the source alpha as a brightness for your background--ie. 0 = totaly black, 1 = totally white). The GL_ZERO means that no source color info is used. I would hope GL_ZERO would skip some math in the blend routine, but I dunno.

Just some additional info to confuse you.

Share this post


Link to post
Share on other sites
I''m also puzzling with a fade to black effect. I basically have the same code as above with

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

my problem is that as soon as i start drawing the fade , so alpha would be 0. The screen looks darker.but with a alpha of 0 i should see the normal screen?

This annoys me since there is a jump in my fade. It looks ok but it''s not what i want ;-)

i didn''t disable lighting, hope that''s going to help

-Airo

Share this post


Link to post
Share on other sites