对未声明的标识符

对未声明的标识符

本文介绍了GLSL:“对未声明的标识符'texture2D'的无效调用";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac上使用Swift和OpenGL 3.2.我也在使用XCode 6.1 Beta,所以我认为这是最可能的解释,因为在我看来这似乎没有道理.

I'm on a Mac, using Swift, and using OpenGL 3.2. I'm also using XCode 6.1 Beta so I suppose that's the most likely explanation, because it doesn't seem to me like this makes sense.

我找不到任何证据不支持此功能,但是此片段着色器在编译期间导致错误Invalid call of undeclared identifier 'texture2D':

I can't find any evidence that this shouldn't be supported, but this fragment shader is resulting in the error Invalid call of undeclared identifier 'texture2D' during compilation:

#version 150

uniform sampler2D usTexture;

in vec2 vTextureCoord;

out vec4 FragColor;

void main() {
  vec4 color = texture2D(usTexture, vTextureCoord);
  FragColor = color;
}

推荐答案

片段.在我发布问题之后,终于找到了答案. texture2D已替换为texture.

Cripes. Finally found the answer right after I posted the question. texture2D has been replaced by texture.

这篇关于GLSL:“对未声明的标识符'texture2D'的无效调用";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 13:31