Drawing a solid sphere with transparency in openGL
10,418
You need to explicitely setup alpha blending . Another example.
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
Comments
-
Etan almost 2 years
I want to draw a
glutSolidSphere
with some transparency, but it doesn't seem to work.glColor4f(1, 0, 0, 0); // should be completely invisible glPushMatrix(); glTranslatef(position.x, position.y, position.z); glutSolidSphere(3, 5, 5); glPopMatrix();
In my main function, I initialize with the following display mode:
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA);
What am I missing here?
-
Etan over 13 yearsThis works now if multiple objects overlap. However, if there is a fully transparent object with nothing behind, it renders the object instead of the background color
-
Etan over 13 yearsvoid renderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
Etan over 13 yearsscriptreactor.com/transparency.png <-- the red spheres should be completely transparent.
-
Etan over 13 yearsokay, had used another blending function accidently. works now. thanks