GL_OES_EGL_image#

Supported Hardware#

Series5, Series5XT, Series6, Series6XE, Series6XT

Valid APIs#

OpenGL ES 1.x, 2.0, 3.x

Description#

The concept of an EGLImage is introduced by EGL_KHR_image_base or EGL_KHR_image, and this extension enables an OpenGL ES implementation to bind EGLImages as if they were textures or renderbuffers, using the functions glEGLImageTargetTexture2DOES and glEGLImageTargetRenderbufferStorageOES, respectively. The format/type of the images must already be supported in OpenGL ES (or analogous to them) so that they work with any existing OpenGL ES queries. Image formats not supported in OpenGL ES natively are supported via the additional extension: GL_OES_EGL_image_external. Textures specified in this way can be sampled as textures or used as framebuffer attachments as if they were native objects.

It should be noted that if a user modifies the storage of the image by calling something like glGenerateMipMaps or glTexImage2D, then the driver will allocate new memory and copy relevant data across (if applicable). This will dissociate the GL texture object from the original EGLImage, and the two will be completely separate and independent.

Example#

// Create an EGL image via EGL_KHR_image_base. In this case from an EGL pixmap
// (EGL_KHR_image_pixmap), but the source is irrelevant to this example
EGLImageKHR eglImage = eglCreateImageKHR(eglDisplay, eglContext, EGL_NATIVE_PIXMAP_KHR, (EGLNativeBuffer)eglPixmap, NULL);
// Generate a texture object to map the EGLImage to, and bind it.
GLint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
// Map the EGLImage into an OpenGL ES texture using this extension.
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)eglImage);
// This extension now allows an application to attach this to a framebuffer
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);