@Override public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) { GL2 gl2 = arg0.getGL().getGL2(); gl2.glMatrixMode(GL2.GL_PROJECTION); gl2.glLoadIdentity(); // coordinate system origin at lower left with width and height same as the window GLU glu = new GLU(); glu.gluOrtho2D(0.0f, getWidth(), 0.0f, getHeight()); gl2.glMatrixMode(GL2.GL_MODELVIEW); gl2.glLoadIdentity(); gl2.glViewport(0, 0, getWidth(), getHeight()); controller.updateExtents(arg3 / 2, arg4 / 2); } }
@Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height0) { GL2 gl = drawable.getGL().getGL2(); // get the OpenGL 2 graphics context int height = height0; if (height == 0) { height = 1; // prevent divide by zero } float aspect = (float) width / height; // Set the view port (display area) to cover the entire window gl.glViewport(0, 0, width, height); // Setup perspective projection, with aspect ratio matches viewport gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); // choose projection matrix gl.glLoadIdentity(); // reset projection matrix glu.gluPerspective(45.0, aspect, 0.1, 100.0); // fovy, aspect, zNear, // zFar // Enable the model-view transform gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glLoadIdentity(); // reset }
shared.settings.texwidth, shared.settings.texheight, 0, // Size GL2.GL_RGBA, GL2.GL_FLOAT, null); gl.glViewport(0, 0, shared.settings.texwidth, shared.settings.texheight);
@Override public void init( final GLAutoDrawable drawable ) { final GL2 gl = drawable.getGL().getGL2(); gl.setSwapInterval( 1 ); gl.glEnable( GL.GL_DEPTH_TEST ); gl.glDepthFunc( GL.GL_LEQUAL ); gl.glShadeModel( GLLightingFunc.GL_SMOOTH ); gl.glHint( GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST ); // gl.glEnable( GL.GL_BLEND ); // gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA ); gl.glEnable( GL2GL3.GL_POLYGON_SMOOTH ); final float w = this.window.getDrawableSurface().getWidth(); final float h = this.window.getDrawableSurface().getHeight(); // Set the projection matrix (only done once - just here) gl.glMatrixMode( GLMatrixFunc.GL_PROJECTION ); gl.glLoadIdentity(); this.glu.gluPerspective( 50, (w / h), 0.01, 10 ); // Set the initial model matrix gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW ); gl.glLoadIdentity(); gl.glViewport( 0, 0, (int) w, (int) h ); /* viewport size in pixels */ }
gl2.glViewport(0, 0, view_width_, view_height_); gl2.glMatrixMode(gl2.GL_PROJECTION); gl2.glLoadIdentity();