简体   繁体   中英

How to emulate GL_TEXTURE_EXTERNAL_OES texture?

I have a OpenGL ES 2.0 QNX application that uses camera input, makes some processing and renders something to screen.

All my shaders take GL_TEXTURE_EXTERNAL_OES texture from the camera as input and it's format is YUV422.

I want to test my application on the target platform (QNX) using RGB images in png format.

The question is: how can I create GL_TEXTURE_EXTERNAL_OES texture from RGB image to emulate the input from the camera for my application?

Answering own question.

Steps to create GL_TEXTURE_EXTERNAL_OES texture from RGB buffer on QNX.

1.Converting RGB to YUV422 format on CPU

2.Creating pixmap buffer using screen

EGLNativePixmapType pObjEglPixmap = ...

3.Binding pixmap to GL_TEXTURE_EXTERNAL_OES texture using EGLImageKHR object

EGLImageKHR pObjTextureEglImage = eglCreateImageKHR(eglDisplay,
                                                    EGL_NO_CONTEXT,
                                                    EGL_NATIVE_PIXMAP_KHR,
                                                    pObjEglPixmap,
                                                    NULL);

GLuint pObjTextureId;
glGenTextures(1, &pObjTextureId);

glBindTexture(GL_TEXTURE_EXTERNAL_OES, pObjTextureId);

glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, 
                             (GLeglImageOES)pObjTextureEglImage);

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