gluUnproject returns invalid enumerant

I’ve been using gluUnproject for a while without problem, but lately in revising some code I don’t get any conversion returned and glError() returns error code 1280 which gluErrorString returns as “invalid enumerant”.

Anybody know what I’m doing wrong, and what the code means

gluUnproject does not generate any error codes according to the spec. Try enabling the debug pipeline. That should give you a more precise indication of where the error is.

Thanks. When I enable the debug pipeline via:

glCanvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
glCanvas.setGL(new DebugGL(glCanvas.getGL()));

i only have to do this once at the begining right? Then any erros will be dumped in details, right?

Well no luck. I enable the debug pipeline and there are no error messages, or stack traces. Anybody know where I should look.

I save the projection and model matrices when the scene was being drawn and use it after all the rendering has been completed to determine the mouse coiordinates for viewing. I looked at the matrix arrays and they are the same when calling gluUnproject as they were when rendering thge scene.

Its supposed to be just matrix algebra. Any idea what I’m missing.

Heeeellllppppp!1

I don’t remember exactly the state the top-of-tree JOGL sources are in (all of the work for the past six months has gone into the JSR-231 branch, which should be released in early draft form soon) but if you install the DebugGL pipeline in your GLEventListener’s init() method that should cover all situations.

If you’re getting a GL error during un-projection then using the DebugGL should track down the problem. In a pinch you could hack the sources to see where the problem is being generated. The code path for gluUnproject is all Java and uses the GL object from the GLCanvas.

Ok, anybody know matrix algebra.

Inside gluUnproject the first steps are:

  1.  __gluMultMatricesd(modelMatrix, projMatrix, finalMatrix);
    

then
2) if (!__gluInvertMatrixd(finalMatrix, finalMatrix))
return false;

The routine is retunring from 2 with the error:

[quote]No non-zero pivot. The matrix is singular, which shouldn’t
happen. This means the user gave us a bad matrix.here.
[/quote]
Now I have the following inside my display method:

gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(fov_y, aspect, near_z, far_z);

/* Save projection matrix for later use */
gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, proj);

gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(eye[0], eye[1], -eye[2],
lookat[0], 1f, -lookat[2],
0f, 1f, 0f);

/* Save modelview matrix for later use */
gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, model);

Now here is where i place my unproject function to determine the world coordinates of an x,y screen location, and it retunrs as described above. What is confusing me is that the various objects that I render display ok. I just can’t get the screen coordinates converted to world coordinates.

Any thoughts.

Here’s already some information on matrix inversion
http://192.18.37.44/forums/index.php?topic=10069.msg79973#msg79973
http://mathworld.wolfram.com/MatrixInverse.html
Could you post the concrete values you are passing to gluPerspective and gluLookAt?

eye[1564.0,5102.9976,1396.0]
lookat[1564.0,10.0,1397.0]
fov_x[45.0]
fov_y[42.80306]
aspect=[1.0568655]
viewport[762,721]
near_z[0.0]
far_z[51029.977]
canvas_width[762]
canvas_height[721]

projection matrix
[2.4142134189605713][0.0][0.0][0.0]
[0.0][2.5514988899230957][0.0][0.0]
[0.0][0.0][-1.0][-1.0]
[0.0][0.0][-0.0][0.0]

modelview matrix
[1.0][0.0][0.0][0.0]
[0.0][1.9600165251176804E-4][1.0][0.0]
[0.0][-1.0][1.9600165251176804E-4][0.0]
[-1564.0][-1397.000244140625][-5102.72412109375][1.0]

MOUSE - X=504, Y=193

To quote myself :slight_smile:

Your near_z is set to 0 which is probably the cause of the problem.

yup. That was it. Thanks !!!