You have a couple of problems here:
- You never checked the shader compile log, if you did you would have seen that the fragment shader does not compile.
- You only check
glGetError (...)
after a single call, and thus you thought thatint mvpMatrixHandle = GLES20.glGetUniformLocation(m_program, "uMVPMatrix");
was the source of yourGL_INVALID_OPERATION
, when in factglUseProgram (...)
was the first line of code in your function to trigger it.
I have corrected your vertex and fragment shaders so that they will compile... you cannot use gl_Position
in a fragment shader, and this is why your shader was failing to compile and your program was not linking.
Modified Vertex Shader:
uniform mat4 uMVPMatrix;
attribute vec4 vPosition;
varying vec4 vtx_pos;
void main()
{
gl_Position = uMVPMatrix * vPosition;
vtx_pos = gl_Position;
}
Modified Fragment Shader:
varying vec4 vtx_pos;
uniform float time; // Used for texture animation
float snoise(vec3 v) {
// ..
}
void main( void )
{
vec3 v_texCoord3D = vtx_pos.xyz;
vec3 uvw = v_texCoord3D + 0.1*vec3(snoise(v_texCoord3D + vec3(0.0, 0.0, time)),
snoise(v_texCoord3D + vec3(43.0, 17.0, time)),
snoise(v_texCoord3D + vec3(-17.0, -43.0, time)));
// Six components of noise in a fractal sum
float n = snoise(uvw - vec3(0.0, 0.0, time));
n += 0.5 * snoise(uvw * 2.0 - vec3(0.0, 0.0, time*1.4));
n += 0.25 * snoise(uvw * 4.0 - vec3(0.0, 0.0, time*2.0));
n += 0.125 * snoise(uvw * 8.0 - vec3(0.0, 0.0, time*2.8));
n += 0.0625 * snoise(uvw * 16.0 - vec3(0.0, 0.0, time*4.0));
n += 0.03125 * snoise(uvw * 32.0 - vec3(0.0, 0.0, time*5.6));
n = n * 0.7;
// A "hot" colormap - cheesy but effective
gl_FragColor = vec4(vec3(1.0, 0.5, 0.0) + vec3(n, n, n), 1.0);
}