Login  Register

GL units and screen coordinates

Posted by Flow on Apr 15, 2011; 10:00pm
URL: https://forum.jogamp.org/GL-units-and-screen-coordinates-tp2826205.html

Hey all,

I'm trying to setup my JOGL environment such as my GL Units ans screen coordinates are the same, but I can't get it.

I read a few other posts on different websites, and I tried this:
public void init(GLAutoDrawable drawable) {
        GL gl = drawable.getGL();
        GLU glu = new GLU();

        // Set the clear color to black
        gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        glu.gluOrtho2D(0.0, 0.0, width, height);
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();
}

Small precision: width and height are the size of my JFrame in pixels (900x700 in this case)!

With this init method, my GL units and screen coordinates should match, shouldn't they?

Thanks a lot!