4

I need some help figuring out what i do wrong when i try to create a framebuffer OES.

outTex = new int[1];
        GLES20.glGenTextures(2, outTex, 0);
        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, outTex[0]);

        GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);

        GLES20.glTexImage2D(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
                0,
                GLES11Ext.GL_RGBA8_OES,
                vp.width,
                vp.height,
                0,
                GLES11Ext.GL_RGBA8_OES,
                GLES20.GL_UNSIGNED_BYTE,
                null);
        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);

        fbo = new int[1];

        GLES11Ext.glGenFramebuffersOES(1, fbo, 0);
        GLES11Ext.glBindFramebufferOES(GLES11Ext.GL_FRAMEBUFFER_OES, fbo[0]);

        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, outTex[0]);

        GLES11Ext.glFramebufferTexture2DOES(
                GLES11Ext.GL_FRAMEBUFFER_OES,
                GLES11Ext.GL_COLOR_ATTACHMENT0_OES,
                GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
                outTex[0],
                0
        );

        int  status = GLES11Ext.glCheckFramebufferStatusOES(GLES11Ext.GL_FRAMEBUFFER_OES);
        if  (status != GLES11Ext.GL_FRAMEBUFFER_COMPLETE_OES) {
            throw  new  RuntimeException("Framebuffer is not complete: " +
                    Integer.toHexString(status));
        }

        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);

        GLES11Ext.glBindFramebufferOES(GLES11Ext.GL_FRAMEBUFFER_OES, 0);

The status i get is 36055 and i have no clue why it is incomplete. For more information, the thing i want to do looks like this:

I want to use an external OES texture (from media player), lets call it tex0, in the next pipeline: tex0 -> GPU process -> (using a framebuffer) results tex1. tex1 must be also GL_TEXTURE_EXTERNAL_OES.

I have tried and succeded to use a TEXTURE_2D binded to the framebuffer and everthing worked using normal a framebuffer.

So i need some help either with what i did wrong in my code or with finding another way (maybe using a normal framebuffer) to obtain a TEXTURE EXTERNAL OES from the GPU.

Thank you very much.

BDL
  • 21,052
  • 22
  • 49
  • 55
Cristian
  • 71
  • 6
  • If it is ogl es 2.0, call glGenFramebuffers(,) – Sung Feb 11 '17 at 19:08
  • The main problem is that i have never worked with external texture and oes framebuffers and i don t really know how to work with them correctly. I have modified the code a bit, i kept the texture as defined above and i removed the "oes" suffixes from framebuffer generation. But now i get gl error 1280 at line glFramebufferTexture2D. – Cristian Feb 11 '17 at 19:39
  • Code looks like this now: GLES20.glGenFramebuffers(1, fbo, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fbo[0]); checkGLError("gen si bind framebuffer"); GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, outTex[0]); GLES20.glFramebufferTexture2D( GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES11Ext.GL_TEXTURE_EXTERNAL_OES, outTex[0], 0 ); – Cristian Feb 11 '17 at 19:42
  • Check the width and height of the textures. It might be you need a POT texture (a power of two). If they are not POT try to replace the vp.width and vp.height when generating the texture to some POT values like 1024 just to see if that fixes the issue. – Matic Oblak Feb 13 '17 at 10:01
  • Did you manage to solve this? I have same issue on iOS. I can create a FBO only with a render buffer, but not with just a texture. My code is quite similar to yours. – Brett Mar 10 '18 at 01:19

1 Answers1

0

From the man pages about the target [first argument] for glTexImage2D:

Specifies the target texture of the active texture unit.

Must be GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_ TEXTURE_CUBE_MAP_POSITIVE_Z, or
GL_T EXTURE_CUBE_MAP_NEGATIVE_Z.

You're trying to call glTexImage2D on a GLES11Ext.GL_TEXTURE_EXTERNAL_OES, which is not one of the above.

From my limited research thus far, you have to actually draw the OES texture into a frame buffer that is bound to a texture_2d. from there you have access to the pixels via the frame buffer or the texture_2d.

pale bone
  • 1,746
  • 2
  • 19
  • 26