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肯定!我把它拿走了。