opengl-esegl

EGLImageTargetTexture2DOES target parameter, when to use TEXTURE_EXTERNAL_OES vs TEXTURE_2D


If I understand correctly from reading the OES_EGL_image_external spec, for the EGLImageTargetTexture2DOES function one can either use the TEXTURE_EXTERNAL_OES target, and then you'll need to sample the EGL image via samplerExternalOES sampler in the shader, or, if the GL_OES_EGL_image extension is supported by the GL context, one can also simply use regular 2D texture samplers with the TEXTURE_2D target.

Assuming I get this right, is there any reason to use TEXTURE_EXTERNAL_OES over TEXTURE_2D besides compatibility with contexts where GL_OES_EGL_image is not available for some reason? Are there even drivers out there that support OES_EGL_image_external without GL_OES_EGL_image, or otherwise have problems just using regular samplers? Regular samplers seem a lot more convenient than having to have special shader versions just for textures imported from EGL images.


Solution

  • The common use case for this is importing YUV video surfaces from camera/video decoders. For these you require the TEXTURE_EXTERNAL_OES binding and matching samplers; the TEXTURE_2D path only handles the traditional RGBA data formats.