// This gets called by the constructor, hopefully only // once but it can be called at any time. Called prior to any // Window creation so it can only set variables, not draw things public void init() { /* initialize the widget */ int width = gl.getWidth(); int height = gl.getHeight(); // Initialize the rendering viewport size to OpenGL gl.viewport(0, 0, width, height); gl.matrixMode(GL.PROJECTION); // Set up the camera mode gl.loadIdentity(); // Reset the transformation matrix if (width <= height) gl.ortho( -50.0, 50.0, -50.0 * (double) height / (double) width, 50.0 * (double) height / (double) width, -1.0, 1.0); else gl.ortho( -50.0 * (double) width / (double) height, 50.0 * (double) width / (double) height, -50.0, 50.0, -1.0, 1.0); gl.matrixMode(GL.MODELVIEW); // Reset to model transforms }