On some devices (so far samsung galaxy note 2 and 3 + Xperia Z1) I get this error thrown by a call to glUniformMatrix4fv(uMatrixLocation, 10, false, matrix, 0) to set the transformation matrix.
The error is:
java.lang.IllegalArgumentException: length - offset < count*16 < needed
at android.opengl.GLES20.glUniformMatrix4fv(Native Method)
and it's caused by this line in my textureShaderProgram code:
glUniformMatrix4fv(uMatrixLocation, 10, false, matrix, 0);
uMatrixLocation
is the location pointer of the matrix var
10 is the number of transformation matrices (so matrix.length() = 10 * 16 = 160)
matrix is the float[] varible containing all the transformation data
and 0 is the offset in the matrix
I've tried to increase the count variable in order to solve it but with no success.
The source code from google where this error is generated is at:
and these particular lines do the check and throw the above error:
_remaining = _env->GetArrayLength(value_ref) - offset;
if (_remaining < count*16) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < count*16 < needed";
goto exit;
}
any clue about why these devices throw the error? Could the cpp file on these devices differ from the other devices?
added 20140114 18:47
These are the float values passed to glUniformMatrix4fv(uMatrixLocation, 10, false, matrix, 0)
in matrix variable:
my float is: 0.5625
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 1.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: -1.0
my float is: 0.0
my float is: 0.0
my float is: -0.8425926
my float is: 0.0
my float is: 1.0
my float is: 0.5625
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 1.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: -1.0
my float is: 0.0
my float is: 0.098958336
my float is: -1.1574074
my float is: 0.0
my float is: 1.0
my float is: 0.5625
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 1.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: -1.0
my float is: 0.0
my float is: -0.296875
my float is: -1.1574074
my float is: -0.0
my float is: 1.0
my float is: 0.5625
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 1.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: -1.0
my float is: 0.0
my float is: -0.098958336
my float is: -1.1574074
my float is: -0.0
my float is: 1.0
my float is: 0.5625
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 1.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: -1.0
my float is: 0.0
my float is: 0.296875
my float is: -1.1574074
my float is: 0.0
my float is: 1.0
my float is: 0.5625
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 1.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: -1.0
my float is: 0.0
my float is: 0.9010416
my float is: -0.8240741
my float is: 0.0
my float is: 1.0
my float is: 0.5625
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 1.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: -1.0
my float is: 0.0
my float is: 0.9010416
my float is: 0.8240741
my float is: 0.0
my float is: 1.0
my float is: 0.5625
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 1.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: -1.0
my float is: 0.0
my float is: 0.9010416
my float is: 0.0
my float is: 0.0
my float is: 1.0
my float is: 0.5625
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 1.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: 0.0
my float is: -1.0
my float is: 0.0
my float is: 0.0
my float is: -1.1574074
my float is: 0.0
my float is: 1.0
and this is my vertex shader:
uniform mat4 u_Matrix[10];
attribute lowp float a_MatrixIndex;
attribute vec4 a_Position;
attribute vec2 a_TextureCoordinates;
attribute vec3 a_Color;
varying vec3 v_Color;
varying vec2 v_TextureCoordinates;
void main()
{
v_Color = a_Color;
int MatrixIndex = int(a_MatrixIndex);
v_TextureCoordinates = a_TextureCoordinates;
gl_Position = u_Matrix[MatrixIndex] * a_Position;
}