Drawing a solid sphere with transparency in openGL

烂漫一生 提交于 2019-12-07 12:51:26

问题


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?


回答1:


You need to explicitely setup alpha blending . Another example.

glEnable (GL_BLEND);

glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);



来源:https://stackoverflow.com/questions/4451399/drawing-a-solid-sphere-with-transparency-in-opengl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!