How to emulate GL_TEXTURE_EXTERNAL_OES texture?
Asked Answered
K

1

11

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?

Knocker answered 24/7, 2018 at 13:48 Comment(0)
K
1

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);
Knocker answered 17/1, 2019 at 8:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.