All I want to do is to display an image on the canvas where the user mouse presses. I try gl.glRasterPos2f(…) and glut.glutBitmapString(…) but It seems x and y coordinates provided by mouse press are not proper arguments and they should be converted to view-port reference system. What is the best way to do this?
Any idea is appreciated.
Thanks…
(x,y) mouse positions are relative to the frame/canvas that you’re actually using to display your scene on, since AWT doesn’t know anything about what you’re actually displaying in there.
Depending on what your view is actually set up as you might be able to use gluUnproject and convert between window and world coords that way, but that has the annoying snag of only being able to be called in the display method. You can always do the math yourself instead though, it basically amounts to finding the inverse of a couple of matrices and multiplying your point by them.
Or if you’re using an ortho view then you can often manually convert between one and the other with a much simpler method.
Thanks for hints.
It seems some work there.