@Override public void reshape( GLAutoDrawable d, int x, int y, int width, int height ) { this.width = width; this.height = height; GL gl = d.getGL(); gl.glMatrixMode( GL.GL_PROJECTION ); gl.glLoadIdentity(); glu.gluPerspective( fov, (float) width / height, nearClippingPlane, farClippingPlane ); gl.glMatrixMode( GL.GL_MODELVIEW ); }
/** * @param gl */ private void reshape( GL gl ) { float aspect = (float) width / (float) height; LOG.trace( "reshape( GLAutoDrawable, " + 0 + ", " + 0 + ", " + width + ", " + height + " ) called, aspect: " + aspect ); gl.glMatrixMode( GL.GL_PROJECTION ); gl.glLoadIdentity(); gl.glViewport( 0, 0, width, height ); glu.gluPerspective( viewParams.getViewFrustum().getFOVY(), aspect, viewParams.getViewFrustum().getZNear(), viewParams.getViewFrustum().getZFar() ); gl.glMatrixMode( GL.GL_MODELVIEW ); }
@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 }
@Override public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ) { float aspect = (float) width / (float) height; LOG.info( "reshape( GLAutoDrawable, " + x + ", " + y + ", " + width + ", " + height + " ) called, aspect: " + aspect ); params.setProjectionPlaneDimensions( width, height ); GL gl = drawable.getGL(); gl.glViewport( x, y, width, height ); gl.glMatrixMode( GL.GL_PROJECTION ); gl.glLoadIdentity(); glu.gluPerspective( params.getViewFrustum().getFOVY(), aspect, params.getViewFrustum().getZNear(), params.getViewFrustum().getZFar() ); // glu.gluPerspective( params.getViewFrustum().getFOVY(), aspect, 0.01, 1000 ); gl.glMatrixMode( GL.GL_MODELVIEW ); }
/** * Apply the camera to a GL context. * * @param gl GL context. */ public void apply(GL2 gl) { // 3D projection gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); // Perspective. glu.gluPerspective(35, ratio, 1, 1000); glu.gluLookAt(distance * sinZ, distance * -cosZ, height, // pos 0, 0, .5, // center 0, 0, 1 // up ); // Change back to model view matrix. gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); // Store the matrixes for reference. gl.glGetIntegerv(GL.GL_VIEWPORT, viewp, 0); gl.glGetDoublev(GLMatrixFunc.GL_MODELVIEW_MATRIX, modelview, 0); gl.glGetDoublev(GLMatrixFunc.GL_PROJECTION_MATRIX, projection, 0); }
gl.glLoadIdentity(); double limits[] = computeFrustumLimits(dc); dc.getGLU().gluPerspective(dc.getView().getFieldOfView().degrees, dc.getView().getViewport().getWidth() / dc.getView().getViewport().getHeight(), limits[0], limits[1]);