OpenGL ES glUniformMatrix bug with sending transposed data

I’ve just spent an hour or two trying to get this code work:

    float *tab = new float[16];
    for (int i = 0; i < 16; i++)
        tab[i] = 0.25f;
    GLint uniformLocation = glGetUniformLocation(gProgram, "vvv");
    glUniformMatrix4fv(uniformLocation, 1, true, tab);
    delete[] tab;

The shader, instead of getting a matrix filled with 0.25, gets same zeroes. However, when I set 3rd param of glUniformMatrix to “false” (that is, the data is non-transposed), everything works fine. I guess this is a driver bug? (I’m using a Tegra2-based device with Android 2.2)

Did you call glUseProgram before using glUniform*? Did you successfully link the program? Is uniformLocation > -1 after glGetUniformLocation?

If all the above are true in your case I guess it’s simply a bug in the Tegra drivers. Can’t confirm it myself here on account of not possessing a smartphone.

glGetUniformLocation returns a valid value. However, I noticed that when I want the matrix to be tranposed (and thus set the third arg. of glUniformMatrix to true) I get erros with glGetError, namely, GL_INVALID_VALUE error.

GL_TRUE is an invalid value. OpenGL ES doesn’t allow you to pass transposed matrices. They must be column-major, and the spec is clear that passing anything other than GL_FALSE is an error.

The only reason ES 2.0 even has that parameter is because desktop GL had it.

I probably should have checked the docs earlier but honestly this is very surprising it works this way. It is here if anyone is interested
Thanks Alfonse for pointing this out.