MouseMovement with JOGL

Please Help,

I posted a question related to this previously but believe I may have put it in the wrong place - if this is considered a re-post I appologize but I hope someone can help.
I have an image rendered in JOGL and would like to be able to “move” it by holding the RIGHT-MOUSE Button down and dragging it. I am sure I have to save the changes in X and Y Coordinates and apply to the glTranslate (maybe?).

I am really looking for some simple code in JOGL that illustrates movement with a mouse drag. I can get some movement but it is jittery and almost random.

Thanks to any one with some help or hints.

Have you looked at the gleem classes in the jogl-demos workspace? You can use them and the associated ExaminerViewer class without needing to know the details of how they’re implemented. You could edit the source code to customize which mouse buttons correspond to which actions. Currently it clicks and drags using the left mouse button.

I will definately take a look at the gleem classes.

Does anybody know where I can see some simple example code using JOGL with mouse interaction such that the user can click and drag the Object around on the screen? I know there are probably easier ways (such as using gleem) but I am trying to learn from the ground-up and any hints or help would be greatly appreciated.

Thanks in advance. :slight_smile:

Code, no. Hints, yes.

Well the way I have it working in my own app anyway, is that I’ve got MouseListeners on the OpenGL canvas, which report back clicks & movement to an input handler. The events generated from the listener already have XY co-ordinates of where the click occurred on the canvas, and translating them to world-co-ordinates is just a matter of adding/subtracting from the current ‘camera’ position.

Once you know where you’ve clicked, you can look for objects in the vicinity, and I think you’ll know what to do from there :wink:

I’m using SWT for the canvas and window, so I’m using it’s Mouse*Listener classes to do this. AWT has it’s own set of listeners if you take a look at the java.awt.event package.