/** * load back the last viewport */ public void popViewPort() { gc.getGL().glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); }
public void setViewport(final int x, final int y, final int width, final int height) { GLContext.getCurrentGL().glViewport(x, y, width, height); }
@Override public boolean run(final GLAutoDrawable drawable) { drawable.getGL().glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); return true; } };
@Override public boolean run(final GLAutoDrawable drawable) { drawable.getGL().glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); return false; // issue re-display w/ new viewport! } };
/** * The default init action to be called once after ctx is being created @ 1st makeCurrent(). * @param sendReshape set to true if the subsequent display call won't reshape, otherwise false to avoid double reshape. **/ public final void init(final GLAutoDrawable drawable, final boolean sendReshape) { synchronized(listenersLock) { final ArrayList<GLEventListener> _listeners = listeners; final int listenerCount = _listeners.size(); if( listenerCount > 0 ) { for (int i=0; i < listenerCount; i++) { final GLEventListener listener = _listeners.get(i) ; // If make ctx current, invoked by invokGL(..), results in a new ctx, init gets called. // This may happen not just for initial setup, but for ctx recreation due to resource change (drawable/window), // hence it must be called unconditional, always. listenersToBeInit.remove(listener); // remove if exist, avoiding dbl init init( listener, drawable, sendReshape, 0==i /* setViewport */); } } else { // Expose same GL initialization if not using any GLEventListener drawable.getGL().glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); } } }
/** * {@inheritDoc} * * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or * {@link #setTileRect(int, int, int, int) tile-rect} has not been set. */ @Override public final void beginTile(final GL gl) throws IllegalStateException, GLException { if( 0 >= imageSize.getWidth() || 0 >= imageSize.getHeight() ) { throw new IllegalStateException("Image size has not been set"); } if( !tileRectSet ) { throw new IllegalStateException("tileRect has not been set"); } validateGL(gl); gl.glViewport( 0, 0, currentTileWidth, currentTileHeight ); if( DEBUG ) { System.err.println("TileRenderer.begin.X: "+this.toString()); } // Do not forget to issue: // reshape( 0, 0, tW, tH ); // which shall reflect tile renderer fileds: currentTileXPos, currentTileYPos and imageSize beginCalled = true; }
@Override public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ) { LOG.trace( "reshape( GLAutoDrawable, " + x + ", " + y + ", " + width + ", " + height + " ) called" ); GL gl = drawable.getGL(); gl.glViewport( x, y, width, height ); gl.glMatrixMode( GL.GL_PROJECTION ); gl.glLoadIdentity(); glu.gluOrtho2D( 0, width, 0, height ); gl.glMatrixMode( GL.GL_MODELVIEW ); gl.glLoadIdentity(); int posX = 0; int posY = 0; gl.glViewport( posX, posY, width, height ); gl.glScaled( width, height, 1 ); }
private final void reshape(final GLEventListener listener, final GLAutoDrawable drawable, final int x, final int y, final int width, final int height, final boolean setViewport, final boolean checkInit) { if(checkInit) { // GLEventListener may need to be init, // in case this one is added after the realization of the GLAutoDrawable synchronized(listenersLock) { if( listenersToBeInit.remove(listener) ) { listener.init(drawable); } } } if(setViewport) { final GL gl = drawable.getGL(); final int glerr0 = gl.glGetError(); if( GL.GL_NO_ERROR != glerr0 ) { System.err.println("Info: GLDrawableHelper.reshape: pre-exisiting GL error 0x"+Integer.toHexString(glerr0)); if(DEBUG) { Thread.dumpStack(); } } drawable.getGL().glViewport(x, y, width, height); } listener.reshape(drawable, x, y, width, height); }
@Override public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ) { LOG.trace( "reshape( GLAutoDrawable, " + x + ", " + y + ", " + width + ", " + height + " ) called" ); GL gl = drawable.getGL(); gl.glViewport( x, y, width, height ); gl.glMatrixMode( GL.GL_PROJECTION ); gl.glLoadIdentity(); glu.gluOrtho2D( 0, width, 0, height ); gl.glMatrixMode( GL.GL_MODELVIEW ); gl.glLoadIdentity(); gl.glScalef( width, height, 1 ); }
/** * @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 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 ); }
/** * Saves the current FBO OpenGL state so that the state can be * restored after this FBO was used * * @return * Returns a Closable which when closed resets the OpenGL FBO state to before * this method was called. * Can be used with the new JRE 7 try block, like: * <br> * <code> * try(SaveClosable c = fbo.use())<br> * {<br> * _____draw something_____<br> * }<br> * </code> */ public SaveClosable use() { //save state int[] viewport = new int[4]; gc.getGL().glGetIntegerv(GL.GL_VIEWPORT, viewport, 0); FboCloser closer = new FboCloser(viewport, currdraw, currread); //binding gc.getGL().glViewport(0, 0, getWidth(), getHeight()); bind(); return closer; }
currentTileHeight = tH; gl.glViewport( 0, 0, tW, tH );
gl.glViewport(0, 0, panelWidth, panelHeight); gl.glViewport(usrViewport[0], usrViewport[1], usrViewport[2], usrViewport[3]);