Archived

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

Xeee

About blending

Recommended Posts

first , i want to know , is there is something called "blending" and another called "alpha blending"? second , how to draw a semitransparent pyramid beside a solid (non-tansparent) one?? i''ve tried to switch on blending like in nehe''s lesson 8 and use the alpha component of the color of each pyramid for this purpose and it didn''t work thanks for help ...Xeee

Share this post


Link to post
Share on other sites
Before drawing the Semi-transparent pyramid call:

glEnable(GL_BLEND);

then when you've finished drawing the semi-transparent pyramid call:

glDisable(GL_BLEND);


"To err is human, to really mess up requires a computer"

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. "
- Albert Einstein


Edited by - Lukerd on February 7, 2002 7:00:05 AM

Share this post


Link to post
Share on other sites
it succeeded but instead of
glDisable(GL_BLEND);
only i have to write
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
and instead of
glEnable(GL_BLEND);
only , i have to write
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
y do i have to turn off depth testing while blending is on and vice versa (Actually i don''t know what is Depth testing!!)??

...Xeee

Share this post


Link to post
Share on other sites
Depth testing is a hardware accelerated z buffer. Its a map of the z location of every pixel on the screen. If the pixel to be drawn to the screen is closer to the camera then the old pixel is overwritten, that way you can have intersecting polygons in your scene. If you''re drawing a pyramid inside of another pyramid, the one inside wont be drawn because of the depth buffer refusing to draw the pixel inside due to the fact its parther away from the camera than the current pixel is.

I hope i made sense, cos im stoned.

Share this post


Link to post
Share on other sites
Thanks , every think worked , but in a scene i was drawing ( the earth with a blended atmosphere and a revolving moon )
the moon doesn't appear behind the amtosphere , thu it does with earth
here is the code and a picture(how to put a pic in this thread??)
  
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer

glTranslatef(0.0,0.0,-6);

glBindTexture(GL_TEXTURE_2D, texture[0]);
glRotatef(angle_y,0.0,1.0,0.0);
glRotatef(angle_x,1.0,0.0,0.0);
glScalef(scale_factor,scale_factor,scale_factor);
glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,earth_emi);
gluSphere(earth,0.5,30,30);

glMaterialfv(GL_FRONT,GL_DIFFUSE,atmo_mat);
glMaterialfv(GL_BACK,GL_DIFFUSE,atmo_mat2);
glBindTexture(GL_TEXTURE_2D,texture[2]);
glEnable(GL_BLEND); // Turn Blending On

glDisable(GL_DEPTH_TEST); // Turn Depth Testing Off

gluSphere(atmo,0.57,40,40);

glBindTexture(GL_TEXTURE_2D,texture[1]);
glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,moon_mat);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glTranslatef(0.0,0.0,-0.8);
glRotatef(angle_y,0.0,1.0,0.0);
gluSphere(moon,0.1,30,30);



...Xeee

Edited by - xeee on February 9, 2002 8:11:59 AM

Share this post


Link to post
Share on other sites
When you disable depth testing, you need to "simulate" it -- make sure that objects are drawn with the correct relative z order to the camera. I'm currently trying to work out an elegant implementation for this, but it is proving difficult.

EDIT: Spelled "objects" as "abozects" (!)

Edited by - Cirian on February 11, 2002 4:27:49 AM

Share this post


Link to post
Share on other sites
Simple answer: Render Blended objects LAST in the scene in their respective Z-order...

eg. If inside a plane looking out the window at another plane. Render your plane, render other plane, render other plane pilot. Then render other plane blended cockpit window. then render your own cockpit window.

Share this post


Link to post
Share on other sites