[JOGL1.1.1->JOGL2] Any changes in gluProject()/gluUnproject ?

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

[JOGL1.1.1->JOGL2] Any changes in gluProject()/gluUnproject ?

Djak
Hi,
I'm tracking a bug in an application since hours and I wonder if someone may have an idea on a problem which seems hard to debug. I'm using a method every drawing cycle, in a valid GLContext, for updating/transforming mouse coordinates in World coordinates system :

___________________________________________________________________
        public Point2d getWorldCoords(int x, int y) {
               
                Point2d coords = new Point2d();
                int viewport[] = new int[4];
                double modelViewMatrix[] = new double[16];
                double projectionMatrix[] = new double[16];
                double projectedCoords[] = new double[3];
                double unprojectedCoords[] = new double[3];
                int realY;

                this.gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport, 0);
                this.gl.glGetDoublev(GL2.GL_MODELVIEW_MATRIX, modelViewMatrix, 0);
                this.gl.glGetDoublev(GL2.GL_PROJECTION_MATRIX, projectionMatrix, 0);

                realY = viewport[3] - (int) y - 1;

                this.glu.gluProject(this.currentCamera.getX(), this.currentCamera.getY(), 0, modelViewMatrix, 0, projectionMatrix, 0, viewport, 0, projectedCoords, 0);

                this.glu.gluUnProject((double) x, (double) realY, projectedCoords[2], modelViewMatrix, 0, projectionMatrix, 0, viewport, 0, unprojectedCoords, 0);

                coords.setXY((float) unprojectedCoords[0], (float) unprojectedCoords[1]);

                // TODO : Debug
                System.out.println(".getWorldCoords(): viewport: " + viewport[0] + ":" + viewport[1] + ":" + viewport[2] + ":" + viewport[3]);
                System.out.println(".getWorldCoords(): mouse x: " + x + " y: " + y);
                System.out.println(".getWorldCoords(): world x: " + coords.getX() + " y: " + coords.getY());
                System.out.println(".getWorldCoords(): real y: " + realY);
               
                return coords;
        }
___________________________________________________________________

viewport, mouse coordinates, real y are ok but World coordinates are always (0.0, 0.0).
I gonna try to get the old matrix values from using 1.1.1 for compare them to new values using JOGL2 but I need to reverse a lot of code for that so any clue is welcome before I'll do that :) if someone have an idea on this or if someone knows a significative change in GLU which may do that (cause I think the "problem" is in GLU).

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: [JOGL1.1.1->JOGL2] Any changes in gluProject()/gluUnproject ?

gouessej
Administrator
Hi!

gluProject and gluUnproject with doubles no more work :( I wrote a bug report about this :( Use floats until I fix this please.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: [JOGL1.1.1->JOGL2] Any changes in gluProject()/gluUnproject ?

Djak
Thank you very much, it woks with floats :)
Bye
Reply | Threaded
Open this post in threaded view
|

Re: [JOGL1.1.1->JOGL2] Any changes in gluProject()/gluUnproject ?

gouessej
Administrator
I will try to fix that but I need some help as I don't know GlueGen very well and the buggy code is autogenerated. I know the root cause.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: [JOGL1.1.1->JOGL2] Any changes in gluProject()/gluUnproject ?

Djak
Thanks, and good luck :)
Reply | Threaded
Open this post in threaded view
|

Re: [JOGL1.1.1->JOGL2] Any changes in gluProject()/gluUnproject ?

gouessej
Administrator
Sven fixed this bug. Use the latest build. I have still some pain with GIT so I did not succeed in committing my fix.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: [JOGL1.1.1->JOGL2] Any changes in gluProject()/gluUnproject ?

Djak
Very nice :)
Thanks again ^^