明明顶点着色器代码中有一大段都是注释掉的无用部分来的(如下)。。。。。
但是为何我删掉注释掉的部分后,就发生编译错误了呢?真的好晕啊。。。。
vShader,glsl(顶点着色器):
#version 150
in vec4 vPosition;
in vec4 vColor;
out vec4 color;
void main()
{
//vec3 angles = radians( theta );
//vec3 c = cos( angles );
//vec3 s = sin( angles );
// Remeber: thse matrices are column-major
//mat4 rx = mat4( 1.0, 0.0, 0.0, 0.0,
//0.0, c.x, s.x, 0.0,
//0.0, -s.x, c.x, 0.0,
color = vColor;
gl_Position = vPosition;
}
fShader.glsl(片元着色器)
#version 150
in vec4 color;
out vec4 fColor;
void main()
{
fColor = color;
}
错误如下:

------解决思路----------------------
你需要指定命名空间等
------解决思路----------------------
偶遇到类似问题都是用
“每次用/*...*/注释掉不同部分再重新编译,直到定位到具体语法出错的位置。”
的方法解决的。
------解决思路----------------------
应该是读取shader源码的代码出问题了,仔细检查一下读出来的内容是否跟实际吻合,比如文本长度是否一致,结尾不要包含无关内容,在合适的地方加空结束符。