Login  Register

2D Picking with Jogl

Posted by Daniel S. on Feb 28, 2011; 12:40pm
URL: https://forum.jogamp.org/2D-Picking-with-Jogl-tp2594712.html

Hi folks,

I'm quite new in programming OpenGl with Jogl.

Actually i'm trying to develop an application which uses picking to get  OpenGl points which are selected by the mouse.

I've found some examples with picking in the web, but all of them refer to picking in 3D.
But my application is only 2D and I'm using the following MatrixMode:
...
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        gl.glOrtho(0, 640, 480, 0, -1, 1);
        gl.glMatrixMode(GL.GL_MODELVIEW);
....
        gl.glBegin(GL.GL_POINTS);  
        gl.glColor3f(1.0f, 0.4f, 1.0f);
        gl.glVertex2d(160.0,120.0);
        gl.glEnd();
...
        gl.glEnable(GL.GL_POINT_SMOOTH);
        gl.glPointSize(60.0f);
....
So does anyone know a good tutorial or example which explains picking in 2D?

This would be great.

Thanks in advance,
Daniel