切换到GLSL 300时,遇到以下错误 [英] When switching to GLSL 300, met the following error
本文介绍了切换到GLSL 300时,遇到以下错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我切换为在GLSL 300上使用OpenGL ES 3时,在碎片着色器中遇到以下错误
when I switch to use OpenGL ES 3 with GLSL 300, I met the following error in my frag shader
未声明的标识符gl_FragColor
undeclared identifier gl_FragColor
使用GLSL 100时,一切都很好.
when using GLSL 100, everything is fine.
推荐答案
现代版本的GLSL只需将片段声明为out
值即可执行片段着色器输出,并且不再支持gl_FragColor
,因此会出现错误.试试这个:
Modern versions of GLSL do fragment shader outputs simply by declaring them as out
values, and gl_FragColor
is no longer supported, hence your error. Try this:
out vec4 fragColor;
void main()
{
fragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
请注意,gl_FragDepth
尚未更改,仍然可用.
Note that gl_FragDepth
hasn't changed and is still available.
有关更多信息,请参见 https://www.opengl.org/wiki/Fragment_Shader
For more information see https://www.opengl.org/wiki/Fragment_Shader
这篇关于切换到GLSL 300时,遇到以下错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文