简体   繁体   中英

Is it possible to use EXTERNAL_TEXTURE_OES to render into renderbuffer with TEXTURE_2D?

I'm going to draw Bitmap or text over video frame. Frames comes from camera and are GlUtil.TEXTURE_OES however my pictures are GLES20.GL_TEXTURE_2D The way to combine them - is rendering to framebuffer. As I know, TEXTURE_OES is not supported by framebuffer.

How to solve this situation?

The frames are most likely to be in YUV420 format from the camera. If not you will find other formulas for converting them to RGB on the fly using a fragment shader. Here's the fragment shader I currently use for YUV420:

#ifdef GL_ES
precision mediump float;
#endif

uniform sampler2D u_texturey;
uniform sampler2D u_textureu;
uniform sampler2D u_texturev;
varying vec2 v_texcoord;
varying vec4 v_colorout;

void main(void)
{
    float y = texture2D(u_texturey, v_texcoord).r;
    float u = texture2D(u_textureu, v_texcoord).r - 0.5;
    float v = texture2D(u_texturev, v_texcoord).r - 0.5;
    vec4 rgb = vec4(y + 1.403 * v,
                    y - 0.344 * u - 0.714 * v,
                    y + 1.770 * u,
                    1.0);
    gl_FragColor = rgb * v_colorout;
}

YUV comes in 3 planes so upload them each to their texture units and the GPU does the rest.

Anthing else, just ask.

EDIT:

Use GL_LUMINANCE instead of GL_RGBA for uploading each of the textures data in their planar formats.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM