PDA

View Full Version : glBlend



kentut
07-11-2003, 06:05 AM
I don't know why this code doesn't make my sphere to be transparent.
Should I have something that's not "Solid"? like (if there is any) glutSphere(...)?

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GLfloat matcolor01a01[] = {0,1,0,.1};
glMaterialfv(GL_FRONT,GL_AMBIENT,matcolor01a01);
glutSolidSphere(.04,10,10);
glDisable(GL_BLEND);

nexusone
07-11-2003, 06:16 AM
Have you set the objects alpha?

glColor4f( r, g, b, a) a = alpha valus...1.0 = non-transparent, 0.5 simi-transparent, 0.0 = transparent.


Originally posted by kentut:
I don't know why this code doesn't make my sphere to be transparent.
Should I have something that's not "Solid"? like (if there is any) glutSphere(...)?

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GLfloat matcolor01a01[] = {0,1,0,.1};
glMaterialfv(GL_FRONT,GL_AMBIENT,matcolor01a01);
glutSolidSphere(.04,10,10);
glDisable(GL_BLEND);

errno
07-11-2003, 06:29 AM
i assume that lighting is enabled.
the alpha value used in blending with color buffer is the one registered when calling glMaterialfv(GL_FRONT, GL_DIFFUSE, ...).
what value did you set ?
if it is the same than the one for ambient, the sphere will be transparent as nexusone said. you have to set the alpha to 1.0 in order to have solid object.

the solid word in glutSolidSphere mean that the sphere is rendered using filled polygons. the opposite is glutWireSphere which draw a wireframe sphere.

kentut
07-11-2003, 06:37 AM
I put my RGBA values as {0,1,0, 0.1}
so I assume the alpha is 0.1, it should be almost disappear, as in my code:

GLfloat matcolor[] = {0,1,0,.1};
glMaterialfv(GL_FRONT,GL_AMBIENT,matcolor);