Java Code Examples for javax.microedition.khronos.opengles.GL11ExtensionPack#GL_FRAMEBUFFER_COMPLETE_OES

The following examples show how to use javax.microedition.khronos.opengles.GL11ExtensionPack#GL_FRAMEBUFFER_COMPLETE_OES . 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: GLES11Canvas.java    From PhotoMovie with Apache License 2.0 5 votes vote down vote up
private static void checkFramebufferStatus(GL11ExtensionPack gl11ep) {
    int status = gl11ep.glCheckFramebufferStatusOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES);
    if (status != GL11ExtensionPack.GL_FRAMEBUFFER_COMPLETE_OES) {
        String msg = "";
        switch (status) {
            case GL11ExtensionPack.GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES:
                msg = "FRAMEBUFFER_FORMATS";
                break;
            case GL11ExtensionPack.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES:
                msg = "FRAMEBUFFER_ATTACHMENT";
                break;
            case GL11ExtensionPack.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES:
                msg = "FRAMEBUFFER_MISSING_ATTACHMENT";
                break;
            case GL11ExtensionPack.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES:
                msg = "FRAMEBUFFER_DRAW_BUFFER";
                break;
            case GL11ExtensionPack.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES:
                msg = "FRAMEBUFFER_READ_BUFFER";
                break;
            case GL11ExtensionPack.GL_FRAMEBUFFER_UNSUPPORTED_OES:
                msg = "FRAMEBUFFER_UNSUPPORTED";
                break;
            case GL11ExtensionPack.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES:
                msg = "FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
                break;
        }
        throw new RuntimeException(msg + ":" + Integer.toHexString(status));
    }
}
 
Example 2
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;
}
 
Example 3
Source File: PLRenderer.java    From PanoramaGL with Apache License 2.0 4 votes vote down vote up
@Override
public boolean resizeFromLayer(GL11ExtensionPack gl11ep)
{	
	if(mContextSupportsFrameBufferObject && gl11ep != null)
	{
		synchronized(this)
		{
			if(mBackingWidth[0] != mSize.width || mBackingHeight[0] != mSize.height)
			{
				boolean isRunning = mIsRunning;
				if(isRunning)
					mIsRunning = false;
				
				this.destroyFramebuffer(gl11ep);
				this.createFrameBuffer(gl11ep);
				
	            gl11ep.glRenderbufferStorageOES(GL11ExtensionPack.GL_RENDERBUFFER_OES,
	                    GL11ExtensionPack.GL_RGBA8, mSize.width, mSize.height);
	            gl11ep.glFramebufferRenderbufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES,
	                    GL11ExtensionPack.GL_COLOR_ATTACHMENT0_OES,
	                    GL11ExtensionPack.GL_RENDERBUFFER_OES, mColorRenderbuffer[0]);
	            
	            gl11ep.glGetRenderbufferParameterivOES(GL11ExtensionPack.GL_RENDERBUFFER_OES, GL11ExtensionPack.GL_RENDERBUFFER_WIDTH_OES, mBackingWidth, 0);
		        gl11ep.glGetRenderbufferParameterivOES(GL11ExtensionPack.GL_RENDERBUFFER_OES, GL11ExtensionPack.GL_RENDERBUFFER_HEIGHT_OES, mBackingHeight, 0);
		        
		        mViewport.x = -(mViewport.width / 2 - mSize.width / 2);
				mViewport.y = -(mViewport.height / 2 - mSize.height / 2);
				
				if(gl11ep.glCheckFramebufferStatusOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES) != GL11ExtensionPack.GL_FRAMEBUFFER_COMPLETE_OES)
				{
					PLLog.error("PLRenderer::resizeFromLayer", "Failed to make complete framebuffer object %x", gl11ep.glCheckFramebufferStatusOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES));
					return false;
				}
				
				if(isRunning)
					mIsRunning = true;
				return true;
			}
		}
	}
	else
	{
		synchronized(this)
		{
			mViewport.x = -(mViewport.width / 2 - mSize.width / 2);
			mViewport.y = -(mViewport.height / 2 - mSize.height / 2);
		}
	}
	return false;
}
 
Example 4
Source File: PLRenderer.java    From panoramagl with Apache License 2.0 4 votes vote down vote up
@Override
public boolean resizeFromLayer(GL11ExtensionPack gl11ep) {
    if (mContextSupportsFrameBufferObject && gl11ep != null) {
        synchronized (this) {
            if (mBackingWidth[0] != mSize.width || mBackingHeight[0] != mSize.height) {
                boolean isRunning = mIsRunning;
                if (isRunning)
                    mIsRunning = false;

                this.destroyFramebuffer(gl11ep);
                this.createFrameBuffer(gl11ep);

                gl11ep.glRenderbufferStorageOES(GL11ExtensionPack.GL_RENDERBUFFER_OES,
                        GL11ExtensionPack.GL_RGBA8, mSize.width, mSize.height);
                gl11ep.glFramebufferRenderbufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES,
                        GL11ExtensionPack.GL_COLOR_ATTACHMENT0_OES,
                        GL11ExtensionPack.GL_RENDERBUFFER_OES, mColorRenderbuffer[0]);

                gl11ep.glGetRenderbufferParameterivOES(GL11ExtensionPack.GL_RENDERBUFFER_OES, GL11ExtensionPack.GL_RENDERBUFFER_WIDTH_OES, mBackingWidth, 0);
                gl11ep.glGetRenderbufferParameterivOES(GL11ExtensionPack.GL_RENDERBUFFER_OES, GL11ExtensionPack.GL_RENDERBUFFER_HEIGHT_OES, mBackingHeight, 0);

                mViewport.x = -(mViewport.width / 2 - mSize.width / 2);
                mViewport.y = -(mViewport.height / 2 - mSize.height / 2);

                if (gl11ep.glCheckFramebufferStatusOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES) != GL11ExtensionPack.GL_FRAMEBUFFER_COMPLETE_OES) {
                    PLLog.error("PLRenderer::resizeFromLayer", "Failed to make complete framebuffer object %x", gl11ep.glCheckFramebufferStatusOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES));
                    return false;
                }

                if (isRunning)
                    mIsRunning = true;
                return true;
            }
        }
    } else {
        synchronized (this) {
            mViewport.x = -(mViewport.width / 2 - mSize.width / 2);
            mViewport.y = -(mViewport.height / 2 - mSize.height / 2);
        }
    }
    return false;
}