[OpenglES 3.0] How to bind GL_TEXTURE_EXTERNAL_OES texture to framebuffer to render onto OES

Follow EXT_YUV_target, I try to bind OES texture with:

 GLES30.glFramebufferTexture2D(
                GLES30.GL_FRAMEBUFFER,
                GLES30.GL_COLOR_ATTACHMENT0,
                GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
                mOESTextureId,
                0);

Suppose that all ids is inited right.
However when i check the bind status, error status code is 36054,which is GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT

int status = GLES30.glCheckFramebufferStatus(GLES30.GL_FRAMEBUFFER);

Why not GLES30.GL_FRAMEBUFFER_COMPLETE ?

So wired that ,after about 20 times calls when render frames, it return GL_FRAMEBUFFER_COMPLETE

Questions:

  • Are you Checking for GL errors before and after your glFramebufferTexture2D() call? Are there any? If so, which?
  • Have you verified that your driver’s OpenGLES 3.0 implementation advertises support for EXT_YUV_target on your GPU?
  • Does this apply to your situation?
  • Have you looked through these two sections in the OpenGL ES 3.0 Spec for possible reasons:
    • 4.4.4.1 Framebuffer Attachment Completeness
    • 4.4.4.2 Whole Framebuffer Completeness

Show your full creation+setup for the FBO and all FBO attachments (e.g. mOESTextureId). Also show detection of required extensions/support.

Texture setup code:

    public int loadTexture() {
        int[] tex = new int[1];
        GLES30.glGenTextures(1, tex, 0);
        GLES30.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, tex[0]);
        GLES30.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_NEAREST);
        GLES30.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR);
        GLES30.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE);
        GLES30.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE);
        GLES30.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);
        return tex[0];
    }

FBO setup code:

    private int loadFrameBuffer(){
        int[] fbo = new int[1];
        GLES30.glGenFramebuffers(1, fbo,0);
        return fbo[0];
    }

I only attach color attachment.

You didn’t answer any of my questions.

In your sample code, I’m not seeing EGLImageTargetTexture2DOES(), nor the EGLImage creation+setup backing the texture. You’ve provided no backing for your texture object here.

You probably want to read through these extensions:

mSurfaceTexture.updateTexImage(); does the whole thing for me, including EGLImageTargetTexture2DOES(),
updateTexImage() will finally call /frameworks/native/libs/gui/GLConsumer.cpp

 void GLConsumer::EglImage::bindToTextureTarget(uint32_t texTarget) {
     glEGLImageTargetTexture2DOES(texTarget,
             static_cast<GLeglImageOES>(mEglImage));
 }