gluUnproject not working

Hi, the gluUnproject funktion does not create the right values, only 0.0.
i dont know why. Can somebody take a look at my code pls.
this is the part of the draw funktion:


public void draw(GLDrawable drawable){
		GL gl = drawable.getGL();

		gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
		
		gl.glMatrixMode(GL.GL_MODELVIEW);	
               gl.glLoadIdentity();
	
        	double[] mvMatrix = new double[16];
			 double[] projection = new double[16];
			 int[] viewport = new int[4];
			 double[] objx = new double[1];
			 double[] objy = new double[1];
			 double[] objz = new double[1];
			 int realY;
			 gl.glGetDoublev(GL.GL_MODELVIEW, mvMatrix);
			 for (int i = 0; i < mvMatrix.length; i++){
				 System.out.println("mvmatrix: "+mvMatrix[i]);
			 }
			 gl.glGetDoublev(GL.GL_PROJECTION, projection);
			 gl.glGetIntegerv(GL.GL_VIEWPORT, viewport);
			 realY = viewport[3] - mouseY - 1 ;
			 glu.gluUnProject((double)mouseX, (double)realY, 0.0, mvMatrix, projection, viewport, objx, objy, objz);
			 
			 System.out.println("this is it: "+objx[0]+","+objy[0]+","+objz[0]);
			 
		// drawing just a cube
				this.geoobj.drawFromPrimitives();
			
		
		gl.glFlush();
	
	}

the Mousevalues comes from the mouselistener…

Hi, Look at the following thread : http://192.18.37.44/forums/index.php?topic=8615

Hi, still not working. thats argh

You are sure that you use the folowing call to get the z value?

gl.glReadPixels ( clickX, (int)winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, winZ );

yes, i copied it,hehehe but i it is not working… since 2 weeks
do you have any other idea?

Aren’t you drawing your cube after the gluUnproject call…, since you cleared buffers at the beginning of your method 0 values seeems right.

HI, i clear the buffer in the beginning think that its right…
when draw the cube infront of the unproject method, the values are 0.0 too
i just want to transform the mouse windowcoordinates to object coordinates (is this possible at all?)
the coordinates from the object are not important to me, i return them with a feedback mode

You have to do the math to only convert mouse coordinates to object coordinates…
If you use gluUnproject you have to give a coherent value for the depth, so you need to have one…
At least it’s what i understand. Have a look to the code for the unproject, it can help to make a method to convert coordinates.