Java Code Examples for android.opengl.GLES20#glDeleteRenderbuffers()

The following examples show how to use android.opengl.GLES20#glDeleteRenderbuffers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GLSurface.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * オフスクリーンフレームバッファを破棄
 */
@Override
protected void releaseFrameBuffer() {
	final int[] names = new int[1];
	// デプスバッファがある時はデプスバッファを破棄
	if (mDepthBufferObj >= 0) {
		names[0] = mDepthBufferObj;
		GLES20.glDeleteRenderbuffers(1, names, 0);
		mDepthBufferObj = -1;
	}
	// オフスクリーンのカラーバッファ用のテクスチャを破棄
	if (mFBOTexId >= 0) {
		names[0] = mFBOTexId;
		GLES20.glDeleteTextures(1, names, 0);
		mFBOTexId = -1;
	}
	// オフスクリーンのフレームバッファーオブジェクトを破棄
	if (mFrameBufferObj >= 0) {
		names[0] = mFrameBufferObj;
		GLES20.glDeleteFramebuffers(1, names, 0);
		mFrameBufferObj = -1;
	}
}
 
Example 2
Source File: FBORender.java    From EZFilter with MIT License 6 votes vote down vote up
@Override
public void destroy() {
    super.destroy();
    if (mFrameBuffer != null) {
        GLES20.glDeleteFramebuffers(1, mFrameBuffer, 0);
        mFrameBuffer = null;
    }
    if (mDepthRenderBuffer != null) {
        GLES20.glDeleteRenderbuffers(1, mDepthRenderBuffer, 0);
        mDepthRenderBuffer = null;
    }
    if (mTextureOut != null) {
        GLES20.glDeleteTextures(1, mTextureOut, 0);
        mTextureOut = null;
    }
}
 
Example 3
Source File: JPGFileEndpoint.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void initFBO() {
	if(frameBuffer != null) {
		GLES20.glDeleteFramebuffers(1, frameBuffer, 0);
		frameBuffer = null;
	}
	if(texture_out != null) {
		GLES20.glDeleteTextures(1, texture_out, 0);
		texture_out = null;
	}
	if(depthRenderBuffer != null) {
		GLES20.glDeleteRenderbuffers(1, depthRenderBuffer, 0);
		depthRenderBuffer = null;
	}
	frameBuffer = new int[1];
	texture_out = new int[1];
	depthRenderBuffer = new int[1];
	GLES20.glGenFramebuffers(1, frameBuffer, 0);
	GLES20.glGenRenderbuffers(1, depthRenderBuffer, 0);
	GLES20.glGenTextures(1, texture_out, 0);
	
	GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffer[0]);
	
	GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
	GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture_out[0]);
	GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, getWidth(), getHeight(), 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
	GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
	GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
	GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
	GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
	GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texture_out[0], 0);
	
	GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, depthRenderBuffer[0]);
	GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, getWidth(), getHeight());
	GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, depthRenderBuffer[0]);
	
	int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
	if (status != GLES20.GL_FRAMEBUFFER_COMPLETE) {
		throw new RuntimeException(this+": Failed to set up render buffer with status "+status+" and error "+GLES20.glGetError());
	}
}
 
Example 4
Source File: FrameBufferSource.java    From Tanks with MIT License 5 votes vote down vote up
@Override
public void release(FrameBuffer frameBuffer)
{
  GLES20.glDeleteFramebuffers(1, new int[] { frameBuffer.frameBufferHandle }, 0);
  GLES20.glDeleteRenderbuffers(1, new int[]{ frameBuffer.renderTextureHandle }, 0);
  GLES20.glDeleteTextures(1, new int[]{ frameBuffer.depthTextureHandle }, 0);
}
 
Example 5
Source File: RecordFBOActivity.java    From pause-resume-video-recording with Apache License 2.0 5 votes vote down vote up
/**
 * Releases most of the GL resources we currently hold.
 * <p>
 * Does not release EglCore.
 */
private void releaseGl() {
    GlUtil.checkGlError("releaseGl start");

    int[] values = new int[1];

    if (mWindowSurface != null) {
        mWindowSurface.release();
        mWindowSurface = null;
    }
    if (mProgram != null) {
        mProgram.release();
        mProgram = null;
    }
    if (mOffscreenTexture > 0) {
        values[0] = mOffscreenTexture;
        GLES20.glDeleteTextures(1, values, 0);
        mOffscreenTexture = -1;
    }
    if (mFramebuffer > 0) {
        values[0] = mFramebuffer;
        GLES20.glDeleteFramebuffers(1, values, 0);
        mFramebuffer = -1;
    }
    if (mDepthBuffer > 0) {
        values[0] = mDepthBuffer;
        GLES20.glDeleteRenderbuffers(1, values, 0);
        mDepthBuffer = -1;
    }
    if (mFullScreen != null) {
        mFullScreen.release(false); // TODO: should be "true"; must ensure mEglCore current
        mFullScreen = null;
    }

    GlUtil.checkGlError("releaseGl done");

    mEglCore.makeNothingCurrent();
}
 
Example 6
Source File: FURenderer.java    From FuAgoraDemoDroid with MIT License 5 votes vote down vote up
private void deleteFBO() {
    if (fboId == null || fboTex == null || renderBufferId == null) {
        return;
    }
    GLES20.glDeleteFramebuffers(2, fboId, 0);
    GLES20.glDeleteTextures(2, fboTex, 0);
    GLES20.glDeleteRenderbuffers(2, renderBufferId, 0);
    fboId = null;
    fboTex = null;
    renderBufferId = null;
}
 
Example 7
Source File: FrameBuffer.java    From AAVT with Apache License 2.0 5 votes vote down vote up
/**
 * 销毁FrameBuffer
 */
public void destroyFrameBuffer(){
    if(mFrameTemp!=null){
        GLES20.glDeleteFramebuffers(1,mFrameTemp,0);
        GLES20.glDeleteTextures(1,mFrameTemp,1);
        if(mFrameTemp[2]>0){
            GLES20.glDeleteRenderbuffers(1,mFrameTemp,2);
        }
        mFrameTemp=null;
    }
}
 
Example 8
Source File: EFramebufferObject.java    From SimpleVideoEdit with Apache License 2.0 5 votes vote down vote up
public void release() {
    final int[] args = new int[1];
    args[0] = texName;
    GLES20.glDeleteTextures(args.length, args, 0);
    texName = 0;
    args[0] = renderbufferName;
    GLES20.glDeleteRenderbuffers(args.length, args, 0);
    renderbufferName = 0;
    args[0] = framebufferName;
    GLES20.glDeleteFramebuffers(args.length, args, 0);
    framebufferName = 0;
}
 
Example 9
Source File: MDDrawingCache.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 4 votes vote down vote up
private void createFrameBuffer(int width, int height){

        if (this.mTextureIdOutput != 0) {
            GLES20.glDeleteTextures(1, new int[] { this.mTextureIdOutput}, 0);
        }
        if (this.mRenderBufferId != 0) {
            GLES20.glDeleteRenderbuffers(1, new int[] { this.mRenderBufferId }, 0);
        }
        if (this.mFrameBufferId != 0) {
            GLES20.glDeleteFramebuffers(1, new int[] { this.mFrameBufferId }, 0);
        }

        GLES20.glGetIntegerv(GLES20.GL_FRAMEBUFFER_BINDING, originalFramebufferId, 0);

        // frame buffer
        int[] frameBuffer = new int[1];
        GLES20.glGenFramebuffers(1, frameBuffer, 0);
        GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffer[0]);
        mFrameBufferId = frameBuffer[0];
        glCheck("Multi Fish Eye frame buffer");

        // renderer buffer
        final int[] renderbufferIds = { 0 };
        GLES20.glGenRenderbuffers(1, renderbufferIds, 0);
        GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, renderbufferIds[0]);
        GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, width, height);
        mRenderBufferId = renderbufferIds[0];
        glCheck("Multi Fish Eye renderer buffer");

        final int[] textureIds = { 0 };
        GLES20.glGenTextures(1, textureIds, 0);
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureIds[0]);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, (Buffer)null);
        mTextureIdOutput = textureIds[0];
        glCheck("Multi Fish Eye texture");

        // attach
        GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, mTextureIdOutput, 0);
        GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, renderbufferIds[0]);
        glCheck("Multi Fish Eye attach");

        // check
        final int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
        if (status != GLES20.GL_FRAMEBUFFER_COMPLETE) {
            final String s = "Framebuffer is not complete: ";
            final String value = String.valueOf(Integer.toHexString(status));
            throw new RuntimeException((value.length() != 0) ? s.concat(value) : s);
        }

        GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, originalFramebufferId[0]);
        glCheck("Multi Fish Eye attach");
    }
 
Example 10
Source File: Renderbuffer.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
public void delete() {
	int[] buffers = {id};
	GLES20.glDeleteRenderbuffers( 1, buffers, 0 );
}
 
Example 11
Source File: OGLESShaderRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void deleteRenderBuffer(FrameBuffer fb, RenderBuffer rb) {
        intBuf1.put(0, rb.getId());
        GLES20.glDeleteRenderbuffers(1, intBuf1);
//        RendererUtil.checkGLError();
    }
 
Example 12
Source File: Renderbuffer.java    From remixed-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public void delete() {
	int[] buffers = {id};
	GLES20.glDeleteRenderbuffers( 1, buffers, 0 );
}
 
Example 13
Source File: Renderbuffer.java    From PD-classes with GNU General Public License v3.0 4 votes vote down vote up
public void delete() {
	int[] buffers = {id};
	GLES20.glDeleteRenderbuffers( 1, buffers, 0 );
}
 
Example 14
Source File: GLTextureOutputRenderer.java    From AndroidFastImageProcessing with MIT License votes vote down vote up
@Override
	public void destroy() {
		super.destroy();
		if(frameBuffer != null) {
			GLES20.glDeleteFramebuffers(1, frameBuffer, 0);
			frameBuffer = null;
		}
		if(texture_out != null) {
			GLES20.glDeleteTextures(1, texture_out, 0);
			texture_out = null;
		}
		if(depthRenderBuffer != null) {
			GLES20.glDeleteRenderbuffers(1, depthRenderBuffer, 0);
			depthRenderBuffer = null;
		}
	} 
Example 15
Source File: TwoPassFilter.java    From UltimateAndroid with Apache License 2.0 votes vote down vote up
private void initFBO() {
		if(firstPassFrameBuffer != null) {
			GLES20.glDeleteFramebuffers(1, firstPassFrameBuffer, 0);
			firstPassFrameBuffer = null;
		}
		if(firstPassTextureOut != null) {
			GLES20.glDeleteTextures(1, firstPassTextureOut, 0);
			firstPassTextureOut = null;
		}
		if(firstPassDepthRenderBuffer != null) {
			GLES20.glDeleteRenderbuffers(1, firstPassDepthRenderBuffer, 0);
			firstPassDepthRenderBuffer = null;
		}
		firstPassFrameBuffer = new int[1];
		firstPassTextureOut = new int[1];
		firstPassDepthRenderBuffer = new int[1];
		GLES20.glGenFramebuffers(1, firstPassFrameBuffer, 0);
		GLES20.glGenRenderbuffers(1, firstPassDepthRenderBuffer, 0);
		GLES20.glGenTextures(1, firstPassTextureOut, 0);
		
		GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, firstPassFrameBuffer[0]);
		
		GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, firstPassTextureOut[0]);
		GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGB, getWidth(), getHeight(), 0, GLES20.GL_RGB, GLES20.GL_UNSIGNED_SHORT_5_6_5, null);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
		GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, firstPassTextureOut[0], 0);
		
		GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, firstPassDepthRenderBuffer[0]);
		GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, getWidth(), getHeight());
		GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, firstPassDepthRenderBuffer[0]);
		
		int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
		if (status != GLES20.GL_FRAMEBUFFER_COMPLETE) {
			throw new RuntimeException(this+": Failed to set up render buffer with status "+status+" and error "+GLES20.glGetError());
		}
	} 
Example 16
Source File: BitmapOutput.java    From UltimateAndroid with Apache License 2.0 votes vote down vote up
private void initFBO() {
		if(frameBuffer != null) {
			GLES20.glDeleteFramebuffers(1, frameBuffer, 0);
			frameBuffer = null;
		}
		if(texture_out != null) {
			GLES20.glDeleteTextures(1, texture_out, 0);
			texture_out = null;
		}
		if(depthRenderBuffer != null) {
			GLES20.glDeleteRenderbuffers(1, depthRenderBuffer, 0);
			depthRenderBuffer = null;
		}
		frameBuffer = new int[1];
		texture_out = new int[1];
		depthRenderBuffer = new int[1];
		GLES20.glGenFramebuffers(1, frameBuffer, 0);
		GLES20.glGenRenderbuffers(1, depthRenderBuffer, 0);
		GLES20.glGenTextures(1, texture_out, 0);
		
		GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffer[0]);
		
		GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture_out[0]);
		GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, getWidth(), getHeight(), 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
		GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texture_out[0], 0);
		
		GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, depthRenderBuffer[0]);
		GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, getWidth(), getHeight());
		GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, depthRenderBuffer[0]);
		
		int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
		if (status != GLES20.GL_FRAMEBUFFER_COMPLETE) {
			throw new RuntimeException(this+": Failed to set up render buffer with status "+status+" and error "+GLES20.glGetError());
		}
	} 
Example 17
Source File: BitmapOutput.java    From AndroidFastImageProcessing with MIT License votes vote down vote up
private void initFBO() {
		if(frameBuffer != null) {
			GLES20.glDeleteFramebuffers(1, frameBuffer, 0);
			frameBuffer = null;
		}
		if(texture_out != null) {
			GLES20.glDeleteTextures(1, texture_out, 0);
			texture_out = null;
		}
		if(depthRenderBuffer != null) {
			GLES20.glDeleteRenderbuffers(1, depthRenderBuffer, 0);
			depthRenderBuffer = null;
		}
		frameBuffer = new int[1];
		texture_out = new int[1];
		depthRenderBuffer = new int[1];
		GLES20.glGenFramebuffers(1, frameBuffer, 0);
		GLES20.glGenRenderbuffers(1, depthRenderBuffer, 0);
		GLES20.glGenTextures(1, texture_out, 0);
		
		GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffer[0]);
		
		GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture_out[0]);
		GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, getWidth(), getHeight(), 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
		GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texture_out[0], 0);
		
		GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, depthRenderBuffer[0]);
		GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, getWidth(), getHeight());
		GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, depthRenderBuffer[0]);
		
		int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
		if (status != GLES20.GL_FRAMEBUFFER_COMPLETE) {
			throw new RuntimeException(this+": Failed to set up render buffer with status "+status+" and error "+GLES20.glGetError());
		}
	} 
Example 18
Source File: BitmapOutput.java    From UltimateAndroid with Apache License 2.0 votes vote down vote up
@Override
	public void destroy() {
		super.destroy();
		if(frameBuffer != null) {
			GLES20.glDeleteFramebuffers(1, frameBuffer, 0);
			frameBuffer = null;
		}
		if(texture_out != null) {
			GLES20.glDeleteTextures(1, texture_out, 0);
			texture_out = null;
		}
		if(depthRenderBuffer != null) {
			GLES20.glDeleteRenderbuffers(1, depthRenderBuffer, 0);
			depthRenderBuffer = null;
		}
	} 
Example 19
Source File: GLTextureOutputRenderer.java    From UltimateAndroid with Apache License 2.0 votes vote down vote up
private void initFBO() {
		if(frameBuffer != null) {
			GLES20.glDeleteFramebuffers(1, frameBuffer, 0);
			frameBuffer = null;
		}
		if(texture_out != null) {
			GLES20.glDeleteTextures(1, texture_out, 0);
			texture_out = null;
		}
		if(depthRenderBuffer != null) {
			GLES20.glDeleteRenderbuffers(1, depthRenderBuffer, 0);
			depthRenderBuffer = null;
		}
		frameBuffer = new int[1];
		texture_out = new int[1];
		depthRenderBuffer = new int[1];
		GLES20.glGenFramebuffers(1, frameBuffer, 0);
		GLES20.glGenRenderbuffers(1, depthRenderBuffer, 0);
		GLES20.glGenTextures(1, texture_out, 0);
		
		GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffer[0]);
		
		GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture_out[0]);
		GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, getWidth(), getHeight(), 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
		GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
		GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texture_out[0], 0);
		
		GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, depthRenderBuffer[0]);
		GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, getWidth(), getHeight());
		GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, depthRenderBuffer[0]);
		
		int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
		if (status != GLES20.GL_FRAMEBUFFER_COMPLETE) {
			throw new RuntimeException(this+": Failed to set up render buffer with status "+status+" and error "+GLES20.glGetError());
		}
	} 
Example 20
Source File: BitmapOutput.java    From UltimateAndroid with Apache License 2.0 votes vote down vote up
@Override
	public void destroy() {
		super.destroy();
		if(frameBuffer != null) {
			GLES20.glDeleteFramebuffers(1, frameBuffer, 0);
			frameBuffer = null;
		}
		if(texture_out != null) {
			GLES20.glDeleteTextures(1, texture_out, 0);
			texture_out = null;
		}
		if(depthRenderBuffer != null) {
			GLES20.glDeleteRenderbuffers(1, depthRenderBuffer, 0);
			depthRenderBuffer = null;
		}
	}