problem creating float array args for gluUnproject

Started by napier, August 13, 2004, 03:20:52

Previous topic - Next topic

napier

I'm converting to version .9 and am stuck on gluUnproject.  How do I convert a matrix as FloatBuffer to a two dimensional float array?  I wrote a function to convert FloatBuffer to float[][]:

   public static float[][] getMatrixAsArray(FloatBuffer fb)
    {
        Matrix4f m = new Matrix4f();
        float[][] fa = new float[4][4];
        m.load(fb);
        fa[0][0] = m.m00;
        fa[0][1] = m.m01;
        fa[0][2] = m.m02;
        fa[0][3] = m.m03;
        fa[1][0] = m.m10;
        fa[1][1] = m.m11;
        fa[1][2] = m.m12;
        fa[1][3] = m.m13;
        fa[2][0] = m.m20;
        fa[2][1] = m.m21;
        fa[2][2] = m.m22;
        fa[2][3] = m.m23;
        return fa;
    }


and I call it like so:

   FloatBuffer modelview = allocFloats(16);
    GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);

    float[][] modelViewA = getMatrixAsArray(modelview);

    GLU.gluUnProject( x, y, z, modelViewA, ... );


The result from gluUnProject is always 0,0,0.  This worked fine in version .8 when I just passed in the modelview matrix as a FloatBuffer.  Anybody have a snip of code to demonstrate the matrix/array conversion?
penGL/Java/LWJGL demos and code: http://potatoland.org/code/gl

napier

oops.   :oops:

Just realized I left out the last row of the matrix in my conversion function.   Amazing what a full night's sleep will do for my debugging abilities.

Problem is solved.
penGL/Java/LWJGL demos and code: http://potatoland.org/code/gl

middy

I asked to have that function added to LWJGL matrix class weeks ago.  :(
um