Drawing a solid sphere with transparency in openGL

I want to draw a glutSolidSphere with some transparency, but it does not 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 the following display mode:

 glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA); 

What am I missing here?

+4
source share
1 answer

You need to explicitly set up alpha blending . Another example .

glEnable (GL_BLEND);

glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

+13
source

Source: https://habr.com/ru/post/1332227/


All Articles