LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: CaseyB on September 27, 2005, 15:40:47

Title: gluUnproject gluProject
Post by: CaseyB on September 27, 2005, 15:40:47
I need to get the location of the mouse pointer at a certain depth into the screen.  I think I would need to use gluProject for this, but the only things that I can find call GLU.gluProject(float, float, float, DoubleBuffer, DoubleBuffer, IntBuffer, DoubleBuffer) but this is apparently old becuase now it seems to require GLU.gluProject(float, float, float, float[][], float[][], int[], float[])First is this what I need and second how do I get the data that it needs to get the points that I need?

-=EDIT=-
What I am trying to accomplish is I want the name of an object to be displayed when the mouse is over it.  Is this even the right track?
Title: gluUnproject gluProject
Post by: napier on September 28, 2005, 00:29:34
project and unproject can convert world space to screen and vice versa.  You need to supply the modelview and perspective matrices and the viewport.  To go from screen to world space you need to supply a Z depth as well since the screen is flat.

I have functions that call project/unproject with all necessary data:
http://potatoland.org/code/gl/GLApp.java

look for "unproject".  Also "getWorldCoordsAtScreen()" is a handy function that I use for find world coords at screen positions.
Title: gluUnproject gluProject
Post by: CaseyB on September 28, 2005, 15:09:10
Is it possible to do picking in an AWTGLCanvas?  I kept running into a null pointer exception so I looked at the source for GL11 in the debugger and it's choking on line 1153long function_pointer = GLContext.getCapabilities().GL11_glGetFloatv_pointer;
It saysbinding == null for GL11_glGetFloatv_pointer
field access attempt on null object @ GLContext.getCapabilities().GL11_glGetFloatv_pointer


What's the deal?  Am I doing something wrong?! (Quite possible as I have no idea how this stuff works yet!)
Title: gluUnproject gluProject
Post by: Mr EEK on October 05, 2005, 19:59:03
Hi CaseyB,

With regard to your original post, there was a thread on javagaming.org recently about un-projection that might help:

http://192.18.37.44/forums/index.php?topic=10970.15

(Don't know anything about AWTGLCanvas, sorry ;))
Title: gluUnproject gluProject
Post by: CaseyB on October 05, 2005, 20:07:24
Thank you very much!!