GLSL: "Invalid call of undeclared identifier 'texture2D'"
Asked Answered
T

1

14

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.

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;
}
Thundercloud answered 8/10, 2014 at 20:49 Comment(0)
T
37

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

Thundercloud answered 8/10, 2014 at 20:58 Comment(2)
Yes, be aware that on OS X #version 150 can only mean #version 150 core. On other platforms where compatibility profiles are implemented, you can continue to use things that were deprecated beginning in GLSL 1.30 such as texture2D if you write #version 150 compatibility. You really don't want that, but it's worth mentioning ;)Fid
What about guys using #version 330. I'm using it and replacing 'texture2D' by 'texture' doesn't solve problem. What should I do?Surly

© 2022 - 2024 — McMap. All rights reserved.