Re: GL units and screen coordinates
Posted by
Wade Walker on
Apr 29, 2011; 1:18pm
URL: https://forum.jogamp.org/GL-units-and-screen-coordinates-tp2826205p2879145.html
Julien is right as usual

Normally I do something like this:
gl.glMatrixMode( GL.GL_PROJECTION );
gl.glLoadIdentity();
glu.gluOrtho2D( -(fObjectUnitsPerPixel * iWidth) / 2.0f,
(fObjectUnitsPerPixel * iWidth) / 2.0f,
-(fObjectUnitsPerPixel * iHeight) / 2.0f,
(fObjectUnitsPerPixel * iHeight) / 2.0f );
gl.glMatrixMode( GL.GL_MODELVIEW );
gl.glViewport( 0, 0, iWidth, iHeight );
gl.glLoadIdentity();
gl.glTranslatef( fViewTranslateX, fViewTranslateY, 0.0f );
When fObjectUnitsPerPixel = 1.0, there's no zoom. Decreasing fObjectUnitsPerPixel zooms you in, and increasing it zooms you out. fViewTranslateX and fViewTranslateY are used to pan the viewport around.