I am drawing a flat image in an XY plane. In the example that I posted z[0] is the z value of that plane. Here is my code:
projectionBuff.rewind();
modelBuff.rewind();
viewportBuff.rewind();
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionBuff);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelBuff);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewportBuff);
modelBuff.get(modelArray[0]);
modelBuff.get(modelArray[1]);
modelBuff.get(modelArray[2]);
modelBuff.get(modelArray[3]);
projectionBuff.get(projectionArray[0]);
projectionBuff.get(projectionArray[1]);
projectionBuff.get(projectionArray[2]);
projectionBuff.get(projectionArray[3]);
viewportBuff.get(viewportArray);
GLU.gluUnProject((float)mouseX, (float)mouseY, z[0], modelArray, projectionArray, viewportArray, oldResult);
System.out.println("("+oldResult[0]+","+oldResult[1]+")");
The trouble is that I am always getting really small results usually between 1.001E-6 and 7.5E-5. What am I doing wrong?