Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OpenGL淡色方块_Opengl - Fatal编程技术网

OpenGL淡色方块

OpenGL淡色方块,opengl,Opengl,我试图实现一种淡入淡出的效果,正方形的角有不同的字母。我正在这样做: glBegin(GL_QUADS); glColor4d(r, g, b, alphaTopLeft); glVertex2d(x, y); glColor4d(r, g, b, alphaTopRight); glVertex2d(x + width, y); glColor4d(r, g, b, alphaBottomRight); glVertex2d(x + width, y + height); glColor4d

我试图实现一种淡入淡出的效果,正方形的角有不同的字母。我正在这样做:

glBegin(GL_QUADS);

glColor4d(r, g, b, alphaTopLeft);
glVertex2d(x, y);
glColor4d(r, g, b, alphaTopRight);
glVertex2d(x + width, y);
glColor4d(r, g, b, alphaBottomRight);
glVertex2d(x + width, y + height);
glColor4d(r, g, b, alphaBottomLeft);
glVertex2d(x, y + height);

glEnd();

对于值alphaTopLeft=0、alphaTopRight=0、alphaBottomRight=1、alphaBottomLeft=1,但它会生成实心形状(所有角点alpha 1),为什么?

启用了
GL_BLEND
?在渲染之前尝试添加以下内容:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
glEnable( GL_BLEND );

您是否启用了
GL_BLEND
?在渲染之前尝试添加以下内容:
glBlendFunc(GL_SRC_ALPHA,GL_ONE_减去SRC_ALPHA);glEnable(GL_混合物);glClearColor(0.0,0.0,0.0,0.0)glClearColor肯定与混合无关吗?@immibis肯定!我把它拿走了。