我正在使用 Swift 和 OpenGL 3.2,同时在 Mac 上使用 XCode 6.1 Beta。我想这可能是导致错误的最可能原因,因为我找不到任何证据表明这个不支持。
但是,在编译期间,这个片段着色器会导致错误:Invalid call of undeclared identifier 'texture2D'
#version 150
uniform sampler2D usTexture;
in vec2 vTextureCoord;
out vec4 FragColor;
void main() {
vec4 color = texture2D(usTexture, vTextureCoord);
FragColor = color;
}
#version 150
只能表示#version 150 core
。在其他实现兼容性配置文件的平台上,如果你写了#version 150 compatibility
,你可以继续使用 GLSL 1.30 开始被弃用的东西,比如texture2D
。虽然你真的不想这样做,但值得一提 ;) - Andon M. Coleman