我已经为你更正了你的着色器并评论了它们的所有错误。
片段着色器:
#version 100 // OpenGL ES 2.0 uses different version numbers
uniform Sampler2D TexImg;
varying vec2 Pass_Texcoord; // Use varying instead of in for FS inputs
//out vec4 frag_colour; // Invalid in OpenGL ES 2.0
void main ()
{
// Interestingly, you do not use this value anywhere so GLSL will treat this as
// a no-op and remove this when it comes time to compile this shader.
vec4 color = texture2D (TexImg, Pass_Texcoord); // Also, use texture2D
// You must write to gl_FragData [n] or gl_FragColor in OpenGL ES 2.0
gl_FragColor = vec4 (1.0, 0.0, 0.0, 1.0);
}
顶点着色器:
#version 100 // OpenGL ES 2.0 uses different version numbers
attribute vec3 Pos; // Use attribute instead of in for vtx. attribs
attribute vec3 Texcoord; // Use attribute instead of in for vtx. attribs
varying vec2 Poss_Texcoord; // Use varying instead of out for VS outputs
void main ()
{
gl_Position = vec4 (Pos, 1.0);
/* Constructing a vec2 from 4 components is invalid
Poss_Texcoord = vec2 (TexCoord, 1.0); */
Poss_Texcoord = Texcoord.st; // Use this instead
}