Passing an array of matrices

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Passing an array of matrices

fmorat
I'm trying to pass an array of matrices. The problem is that only the first matrix seems to
get passed. Based on my testing it appears that the second one just gets set to zeros.

Has anybody run into this problem?
Any suggestions on what I may be doing wrong?

Any chance it could be a bug with jogl?

This is the java code:

                        int boneMat_loc = gl.glGetUniformLocation(rendering_program_, "boneMat");
                        if(boneMat_loc<0)
                                throw new Exception("Invalid");
                        float[] matrixPalette=
                                    {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
                                      1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0};
                        int count=2;
                        gl.glUniformMatrix4fv(boneMat_loc, count, false,matrixPalette, 0);


This is the partial shader code that receives the matrix:

uniform mat4 boneMat[2];


Any help is greatly appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Passing an array of matrices

gouessej
Administrator
fmorat wrote
Any chance it could be a bug with jogl?
No chance at all, these methods are used in several engines and frameworks based on JOGL 2 (LibGDX, the abandoned JOGL backend of JMonkeyEngine 3, the legacy version of Ardor3D, etc).

I advise you to look at this example written by Xerxes:
https://jogamp.org/cgit/jogl-demos.git/tree/src/demos/es2/RawGL2ES2demo.java?id=HEAD

Look at the line n°411.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Passing an array of matrices

fmorat
Thanks! I finally figured out what was causing the problem. Turns out that I was trying to pass an integer attribute
and for whatever reason it was being passed corrupted.