Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: OpenGL ES glUniformMatrix bug with sending transposed data

  1. #1
    Intern Newbie
    Join Date
    Jul 2009
    Posts
    38

    OpenGL ES glUniformMatrix bug with sending transposed data

    I've just spent an hour or two trying to get this code work:
    Code :
        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)

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    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.

  3. #3
    Intern Newbie
    Join Date
    Jul 2009
    Posts
    38
    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.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    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.

  5. #5
    Intern Newbie
    Join Date
    Jul 2009
    Posts
    38
    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 http://www.khronos.org/opengles/sdk/.../glUniform.xml
    Thanks Alfonse for pointing this out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •