在openGL中绘制一个具有透明度的实心球体 [英] Drawing a solid sphere with transparency in openGL
本文介绍了在openGL中绘制一个具有透明度的实心球体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想画一个 glutSolidSphere
有一些透明度,但它似乎不工作。
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);
我在这里缺少什么?
推荐答案
glEnable(GL_BLEND);
glEnable (GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
这篇关于在openGL中绘制一个具有透明度的实心球体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文