Java Code Examples for javax.microedition.khronos.opengles.GL11ExtensionPack#glBindFramebufferOES()

The following examples show how to use javax.microedition.khronos.opengles.GL11ExtensionPack#glBindFramebufferOES() . 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: PLRenderer.java    From PanoramaGL with Apache License 2.0 6 votes vote down vote up
/**buffer methods*/

protected void createFrameBuffer(GL11ExtensionPack gl11ep)
{
	if(mContextSupportsFrameBufferObject)
	{
        gl11ep.glGenFramebuffersOES(1, mDefaultFramebuffer, 0);
        if(mDefaultFramebuffer[0] <= 0)
        	PLLog.error("PLRenderer::createFrameBuffer", "Invalid framebuffer id returned!");
        gl11ep.glGenRenderbuffersOES(1, mColorRenderbuffer, 0);
        if(mColorRenderbuffer[0] <= 0)
        	PLLog.error("PLRenderer::createFrameBuffer", "Invalid renderbuffer id returned!");
        gl11ep.glBindFramebufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES, mDefaultFramebuffer[0]);
        gl11ep.glBindRenderbufferOES(GL11ExtensionPack.GL_RENDERBUFFER_OES, mColorRenderbuffer[0]);
	}
}
 
Example 2
Source File: FrameBufferObjectActivity.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
public void onDrawFrame(GL10 gl) {
    checkGLError(gl);
    if (mContextSupportsFrameBufferObject) {
        GL11ExtensionPack gl11ep = (GL11ExtensionPack) gl;
        if (DEBUG_RENDER_OFFSCREEN_ONSCREEN) {
            drawOffscreenImage(gl, mSurfaceWidth, mSurfaceHeight);
        } else {
            gl11ep.glBindFramebufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES, mFramebuffer);
            drawOffscreenImage(gl, mFramebufferWidth, mFramebufferHeight);
            gl11ep.glBindFramebufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES, 0);
            drawOnscreen(gl, mSurfaceWidth, mSurfaceHeight);
        }
    } else {
        // Current context doesn't support frame buffer objects.
        // Indicate this by drawing a red background.
        gl.glClearColor(1,0,0,0);
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    }
}
 
Example 3
Source File: GLES11Canvas.java    From PhotoMovie with Apache License 2.0 5 votes vote down vote up
private void setRenderTarget(RawTexture texture) {
    GL11ExtensionPack gl11ep = (GL11ExtensionPack) mGL;

    if (mTargetTexture == null && texture != null) {
        mGLId.glGenBuffers(1, mFrameBuffer, 0);
        gl11ep.glBindFramebufferOES(
                GL11ExtensionPack.GL_FRAMEBUFFER_OES, mFrameBuffer[0]);
    }
    if (mTargetTexture != null && texture == null) {
        gl11ep.glBindFramebufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES, 0);
        gl11ep.glDeleteFramebuffersOES(1, mFrameBuffer, 0);
    }

    mTargetTexture = texture;
    if (texture == null) {
        setSize(mScreenWidth, mScreenHeight);
    } else {
        setSize(texture.getWidth(), texture.getHeight());

        if (!texture.isLoaded()) {
            texture.prepare(this);
        }

        gl11ep.glFramebufferTexture2DOES(
                GL11ExtensionPack.GL_FRAMEBUFFER_OES,
                GL11ExtensionPack.GL_COLOR_ATTACHMENT0_OES,
                GL11.GL_TEXTURE_2D, texture.getId(), 0);

        checkFramebufferStatus(gl11ep);
    }
}
 
Example 4
Source File: PLRenderer.java    From panoramagl with Apache License 2.0 5 votes vote down vote up
/**
 * buffer methods
 */

protected void createFrameBuffer(GL11ExtensionPack gl11ep) {
    if (mContextSupportsFrameBufferObject) {
        gl11ep.glGenFramebuffersOES(1, mDefaultFramebuffer, 0);
        if (mDefaultFramebuffer[0] <= 0)
            PLLog.error("PLRenderer::createFrameBuffer", "Invalid framebuffer id returned!");
        gl11ep.glGenRenderbuffersOES(1, mColorRenderbuffer, 0);
        if (mColorRenderbuffer[0] <= 0)
            PLLog.error("PLRenderer::createFrameBuffer", "Invalid renderbuffer id returned!");
        gl11ep.glBindFramebufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES, mDefaultFramebuffer[0]);
        gl11ep.glBindRenderbufferOES(GL11ExtensionPack.GL_RENDERBUFFER_OES, mColorRenderbuffer[0]);
    }
}
 
Example 5
Source File: FrameBufferObjectActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
private int createFrameBuffer(GL10 gl, int width, int height, int targetTextureId) {
    GL11ExtensionPack gl11ep = (GL11ExtensionPack) gl;
    int framebuffer;
    int[] framebuffers = new int[1];
    gl11ep.glGenFramebuffersOES(1, framebuffers, 0);
    framebuffer = framebuffers[0];
    gl11ep.glBindFramebufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES, framebuffer);

    int depthbuffer;
    int[] renderbuffers = new int[1];
    gl11ep.glGenRenderbuffersOES(1, renderbuffers, 0);
    depthbuffer = renderbuffers[0];

    gl11ep.glBindRenderbufferOES(GL11ExtensionPack.GL_RENDERBUFFER_OES, depthbuffer);
    gl11ep.glRenderbufferStorageOES(GL11ExtensionPack.GL_RENDERBUFFER_OES,
            GL11ExtensionPack.GL_DEPTH_COMPONENT16, width, height);
    gl11ep.glFramebufferRenderbufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES,
            GL11ExtensionPack.GL_DEPTH_ATTACHMENT_OES,
            GL11ExtensionPack.GL_RENDERBUFFER_OES, depthbuffer);

    gl11ep.glFramebufferTexture2DOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES,
            GL11ExtensionPack.GL_COLOR_ATTACHMENT0_OES, GL10.GL_TEXTURE_2D,
            targetTextureId, 0);
    int status = gl11ep.glCheckFramebufferStatusOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES);
    if (status != GL11ExtensionPack.GL_FRAMEBUFFER_COMPLETE_OES) {
        throw new RuntimeException("Framebuffer is not complete: " +
                Integer.toHexString(status));
    }
    gl11ep.glBindFramebufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES, 0);
    return framebuffer;
}