/** * Unbind this FBO, i.e. bind read and write framebuffer to default, see {@link GLBase#getDefaultDrawFramebuffer()}. * * <p>If full FBO is supported, sets the read and write framebuffer individually to default, hence not disturbing * an optional operating MSAA FBO, see {@link GLBase#getDefaultReadFramebuffer()} and {@link GLBase#getDefaultDrawFramebuffer()}</p> * * @param gl the current GL context * @throws GLException */ public final void unbind(final GL gl) throws GLException { if(bound) { if(fullFBOSupport) { // default read/draw buffers, may utilize GLContext/GLDrawable override of // GLContext.getDefaultDrawFramebuffer() and GLContext.getDefaultReadFramebuffer() gl.glBindFramebuffer(GL2ES3.GL_DRAW_FRAMEBUFFER, 0); gl.glBindFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER, 0); } else { gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer } bound = false; } }
@Override protected void blitMSFBO() { final GL gl = GLContext.getCurrentGL(); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, _msfboID); gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, _fboID); gl.getGL2GL3().glBlitFramebuffer(0, 0, _width, _height, 0, 0, _width, _height, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT, GL.GL_NEAREST); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, 0); gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, 0); gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); }
/** * bindet das FBO an den GL Context. */ public void bind() { gc.getGL().glBindFramebuffer(GL.GL_FRAMEBUFFER, id); currdraw = id; currread = id; }
@Override protected void setMSFBO() { final GL gl = GLContext.getCurrentGL(); gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, _msfboID); }
private void bindDrawBuffer(int id) { gc.getGL().glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, id); currdraw = id; }
private void bindReadBuffer(int id) { gc.getGL().glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, id); currread = id; }
/** * Bind this FBO, i.e. bind write framebuffer to {@link #getWriteFramebuffer()}. * * <p> * If multisampling is used, it sets the read framebuffer to the sampling sink {@link #getWriteFramebuffer()}. * </p> * <p> * In case you have attached more than one color buffer, * you may want to setup {@link GL2ES3#glDrawBuffers(int, int[], int)}. * </p> * @param gl the current GL context * @throws GLException */ public final void bind(final GL gl) throws GLException { if(!bound || fbName != gl.getBoundFramebuffer(GL.GL_FRAMEBUFFER)) { checkInitialized(); if( fullFBOSupport ) { gl.glBindFramebuffer(GL2ES3.GL_DRAW_FRAMEBUFFER, getWriteFramebuffer()); // this fb, msaa or normal gl.glBindFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER, getReadFramebuffer()); // msaa: sampling sink, normal: this fb } else { gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, getWriteFramebuffer()); // normal: read/write } bound = true; samplingSinkDirty = true; } }
gl.glBindFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER, fbName); // read from this MSAA fb gl.glBindFramebuffer(GL2ES3.GL_DRAW_FRAMEBUFFER, samplingSink.getWriteFramebuffer()); // write to sampling sink ((GL2ES3)gl).glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, // since MSAA is supported, casting to GL2ES3 is OK GL.GL_COLOR_BUFFER_BIT, GL.GL_NEAREST); gl.glBindFramebuffer(GL2ES3.GL_DRAW_FRAMEBUFFER, 0); gl.glBindFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER, 0); } else { gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer
@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); } }
gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0);
gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, fbName); checkNoError(gl, gl.glGetError(), "FBObject Init.bindFB"); // throws GLException if error if(!gl.glIsFramebuffer(fbName)) {
@Override protected void deactivate() { final GL gl = GLContext.getCurrentGL(); if (_active == 1) { final ReadOnlyColorRGBA bgColor = _parentRenderer.getBackgroundColor(); gl.glClearColor(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), bgColor.getAlpha()); gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); ContextManager.getCurrentContext().popEnforcedStates(); if (_neededClip) { _parentRenderer.popClip(); } } _active--; }
gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, _msfboID); gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_RENDERBUFFER, _mscolorRBID); gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, _fboID); ContextManager.getCurrentContext().pushEnforcedStates(); ContextManager.getCurrentContext().clearEnforcedStates();