@Override public final GL getGL() { final GLContext _context = context; if (_context == null) { return null; } return _context.getGL(); }
public final StringBuilder append(final StringBuilder sb) { sb.append("Version ").append(getGLVersion()).append(" [GL ").append(getGLVersionNumber()).append(", vendor ").append(getGLVendorVersionNumber()); sb.append("], options 0x"); sb.append(Integer.toHexString(ctxOptions)); sb.append(", this "); sb.append(toHexString(hashCode())); sb.append(", handle "); sb.append(toHexString(contextHandle)); sb.append(", isShared "+isShared()+", "); sb.append(getGL()); sb.append(",\n\t quirks: "); if(null != glRendererQuirks) { glRendererQuirks.toString(sb); } else { sb.append("n/a"); } if(getGLDrawable()!=getGLReadDrawable()) { sb.append(",\n\tRead Drawable : "); sb.append(getGLReadDrawable()); sb.append(",\n\tWrite Drawable: "); sb.append(getGLDrawable()); } else { sb.append(",\n\tDrawable: "); sb.append(getGLDrawable()); } return sb; }
@Override public GL getGL() { final GLContext _context = context; return (null == _context) ? null : _context.getGL(); }
@Override public GL getGL() { if( Beans.isDesignTime() ) { return null; } final GLContext _context = context; return (_context == null) ? null : _context.getGL(); }
@Override protected void associateContext(final GLContext glc, final boolean bound) { initialize(bound, glc.getGL()); }
@MainThread protected ContextCapabilities createContextCapabilities() { return new JoglContextCapabilities(_context.getGL()); }
public static final GL getCurrentGL() throws GLException { GLContext curContext = GLContext.getCurrent(); if (curContext == null) { throw new GLException("No OpenGL context current on this thread"); } return curContext.getGL(); }
@Override public GL getGL() { if (Beans.isDesignTime()) { return null; } final GLContext context = getContext(); return (context == null) ? null : context.getGL(); }
private static void dumpGLInfo(final GLDrawableFactoryImpl factory, final AbstractGraphicsDevice device) { final GLContext ctx = factory.getOrCreateSharedContext(device); if(null != ctx) { System.err.println("GLProfile.dumpGLInfo: "+ctx); ctx.makeCurrent(); try { System.err.println(JoglVersion.getGLInfo(ctx.getGL(), null)); } finally { ctx.release(); } } else { System.err.println("GLProfile.dumpGLInfo: shared context n/a"); } }
public static final GL2ES1 getCurrentGL2ES1() throws GLException { GLContext curContext = GLContext.getCurrent(); if (curContext == null) { throw new GLException("No OpenGL context current on this thread"); } return curContext.getGL().getGL2ES1(); }
public static final GL2 getCurrentGL2() throws GLException { GLContext curContext = GLContext.getCurrent(); if (curContext == null) { throw new GLException("No OpenGL context current on this thread"); } return curContext.getGL().getGL2(); }
/** * Returns the GL object bound to this thread current context. * If no context is current, throw an GLException * * @return the current context's GL object on this thread * @throws GLException if no context is current */ public static GL getCurrentGL() throws GLException { final GLContext glc = getCurrent(); if(null==glc) { throw new GLException(getThreadName()+": No OpenGL context current on this thread"); } return glc.getGL(); }
/** * Returns the maximum number of FBO RENDERBUFFER samples * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. */ public final int getMaxRenderbufferSamples() { if( hasFullFBOSupport() ) { final GL gl = getGL(); final int[] val = new int[] { 0 } ; try { gl.glGetIntegerv(GL2ES3.GL_MAX_SAMPLES, val, 0); final int glerr = gl.glGetError(); if(GL.GL_NO_ERROR == glerr) { return val[0]; } else if(DEBUG) { System.err.println("GLContext.getMaxRenderbufferSamples: GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr)); } } catch (final GLException gle) { gle.printStackTrace(); } } return 0; }
@Override protected final void contextMadeCurrent(final GLContext glc, final boolean current) { final GL gl = glc.getGL(); if(current) { if( !initialized ) { throw new GLException("Not initialized: "+this); } fbos[fboIBack].bind(gl); fboBound = true; fboSwapped = false; } else if( fboBound && !fboSwapped ) { swapFBOImpl(glc); swapFBOImplPost(glc); fboBound=false; fboSwapped=true; if(DEBUG_SWAP) { System.err.println("Post FBO swap(@release): done"); } } }
@Override public final void postGL(final Graphics g, final boolean isDisplay) { // Cause OpenGL pipeline to flush its results because // otherwise it's possible we will buffer up multiple frames' // rendering results, resulting in apparent mouse lag final GL gl = joglContext.getGL(); gl.glFinish(); if (Java2D.isFBOEnabled() && Java2D.getOGLSurfaceType(g) == Java2D.FBOBJECT) { // Unbind the framebuffer from our context to work around // apparent driver bugs or at least unspecified behavior causing // OpenGL to run out of memory with certain cards and drivers gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); } }
@Override public void applyInternalTransform( DrawContext dc, boolean textureIdentityActive ) { GL2 gl = GLContext.getCurrent( ).getGL( ).getGL2( ); if ( !textureIdentityActive ) { gl.glMatrixMode( GL2.GL_TEXTURE ); gl.glLoadIdentity( ); } gl.glScaled( scaleX, scaleY, 1 ); }
@Override public final void setSurfaceSize(final GLContext context, final int newWidth, final int newHeight) throws NativeWindowException, GLException { if(DEBUG) { System.err.println("GLFBODrawableImpl.ResizeableImpl setSize: ("+getThreadName()+"): "+newWidth+"x"+newHeight+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); } final int lockRes = lockSurface(); if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { throw new NativeWindowException("Could not lock surface: "+this); } try { // propagate new size final ProxySurface ps = (ProxySurface) getNativeSurface(); final UpstreamSurfaceHook ush = ps.getUpstreamSurfaceHook(); if(ush instanceof UpstreamSurfaceHook.MutableSize) { ((UpstreamSurfaceHook.MutableSize)ush).setSurfaceSize(newWidth, newHeight); } else { throw new InternalError("GLFBODrawableImpl.ResizableImpl's ProxySurface doesn't hold a UpstreamSurfaceHookMutableSize but "+ush.getClass().getName()+", "+ps+", ush"); } if( null != context && context.isCreated() ) { resetSize(context.getGL()); } } finally { unlockSurface(); } } }
private final void swapFBOImplPost(final GLContext glc) { // Safely reset the previous front FBO - after completing propagating swap if(0 <= pendingFBOReset) { final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); reset(glc.getGL(), pendingFBOReset, getSurfaceWidth(), getSurfaceHeight(), samples, caps.getAlphaBits()>0, caps.getDepthBits(), caps.getStencilBits()); pendingFBOReset = -1; } }
protected void drawOffscreen( GLContext glContext ) { OGLStackHandler stack = new OGLStackHandler( ); GL2 gl = glContext.getGL( ).getGL2( ); stack.pushAttrib( gl, GL2.GL_ALL_ATTRIB_BITS ); stack.pushClientAttrib( gl, ( int ) GL2.GL_ALL_CLIENT_ATTRIB_BITS ); stack.pushTexture( gl ); stack.pushModelview( gl ); stack.pushProjection( gl ); GLContext c = offscreenCanvas.getGLContext( ); if ( c != null ) { c.makeCurrent( ); try { offscreenCanvas.paint( ); } catch ( Exception e ) { logWarning( logger, "Trouble drawing to offscreen buffer", e ); } finally { glContext.makeCurrent( ); stack.pop( gl ); } } }
protected void drawOffscreen( GLContext glContext ) { GLSimpleFrameBufferObject fbo = offscreenCanvas.getFrameBuffer( ); OGLStackHandler stack = new OGLStackHandler( ); GL2 gl = glContext.getGL( ).getGL2( ); stack.pushAttrib( gl, GL2.GL_ALL_ATTRIB_BITS ); stack.pushClientAttrib( gl, ( int ) GL2.GL_ALL_CLIENT_ATTRIB_BITS ); stack.pushTexture( gl ); stack.pushModelview( gl ); stack.pushProjection( gl ); fbo.bind( glContext ); try { layout.paintTo( offscreenCanvas.getGlimpseContext( ) ); } catch ( Exception e ) { logWarning( logger, "Trouble drawing to offscreen buffer", e ); } finally { fbo.unbind( glContext ); stack.pop( gl ); } } }