android read pixels from GL_TEXTURE_EXTERNAL_OES

android, opengl-es

Solution

The GL_TEXTURE_EXTERNAL_OES texture target is usually in a YUV color space and glReadPixels() requires the target to be RGB. It probably does not do the color space conversion automatically. However, you could do the conversion in your own fragment shader which renders RGB into another texture and then use glReadPixels() to read that.

texture for YUV420 to RGB conversion in OpenGL ES

Problem

I am trying to read pixels/data from an OpenGL texture which is bound to GL_TEXTURE_EXTERNAL_OES. The reason for binding the texture to that target is because in order get live camera feed on android a SurfaceTexture needs to be created from an OpenGL texture which is bound to GL_TEXTURE_EXTERNAL_OES. Since android uses OpenGL ES I can't use glGetTexImage() to read the image data. Therefore I am binding the target to an FBO and then reading it using readPixels(). This is my code: ``` GLuint framebuffer; glGenFramebuffers(1, &framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); //Attach 2D texture to this FBO glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_EXTERNAL_OES, cameraTexture, 0); status("glFramebufferTexture2D() returned error %d", glGetError()); ``` However I am getting error 1282 (GL_INVALID_OPERATION) for some reason.

Original source

Related problems