Android: Texture's gl states do not match with shader's
Getting an odd error validating my shaders on an android device. (It's an Asus eee Pad running Android 3.1)
Texture's gl states do not match with shader's
Anybody know how to fix this error?
Here is the code generating the error:
GLES20.glValidateProgram(id);
GLES20.glGetProgramiv(id, GLES20.GL_VALIDATE_STATUS, ShaderStatus, 0);
if (ShaderStatus[0] != GLES20.GL_TRUE) {
String glerror = GLES20.glGetProgramInfoLog(id);
throw new Error("ERROR TIME! failed to validate GLSL program");
}
Here is the vertex shader:
#ifdef GL_ES
precision highp float;
#endif
attribute vec3 Position;
attribute vec2 TexCoord;
uniform mat4 Projection;
uniform vec3 Location;
uniform float Angle;
uniform vec3 Scale;
uniform sampler2D Texture;
varying vec2 vTexCoord;
void main(void) {
mat3 RotationMatrix = mat3( cos( -Angle ), -sin( -Angle ), 0.0,
sin( -Angle ), cos( -Angle ), 0.0,
0.0, 0.0, 1.0);
gl_Position = Projection * vec4(RotationMatrix * (Position*Scale) + Location, 1.0);
//vColor = vec4(1.0, 1.0, 1.0, 1.0);
vTexCoord = TexCoord;
}
Here is the fragment shader:
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D Texture;
varying vec2 vTexCoord;
uniform vec4 Color;
void main(void) {
vec4 color = texture2D(Texture, vTexCoord) * Color;
gl_FragColor = c开发者_StackOverflow社区olor;
}
My Tegra3 device would fail the glValidateProgram(). Like 'the swine' mentioned in the comment above, the texture not being bound will cause this.
So I fixed my validation error by only calling glValidateProgram() after the texture has been setup with glActiveTexture() and glBindTexture().
My device with Mali GPU never had problems with this though, so it could be a Tegra thing only.
精彩评论