How to render opengl Texture bound to GL_TEXTURE_EXTERNAL_OES
Unsolved
Qt 6
-
I want to get a texture from eglstream and add a QQuickItem with that texture to the scene graph.
The graphic API is gles2 and is implemented as follows using QSGSimpleTextureNode and QSGTexture,
but it is not displayed normally. it displays only black. May I know what the problem is?QSGNode *CameraTexture::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) { // other codes are omitted. // generate texture and bind if (!glIsTexture(mTexture)) { glGenTextures(1, &mTexture); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTexture); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } // create texturenode QSGSimpleTextureNode* n = NULL; if (!oldNode) { n = new QSGSimpleTextureNode(); n->setTextureCoordinatesTransform(QSGSimpleTextureNode::MirrorVertically); } else { n = dynamic_cast<QSGSimpleTextureNode*>(oldNode); } // create QSGTexture and set to node GLuint textureId = 0; if (mQsgTexture) textureId = mQsgTexture->nativeInterface<QNativeInterface::QSGOpenGLTexture>()->nativeTexture(); if (mQsgTexture == NULL || textureId != mTexture) { mQsgTexture = QNativeInterface::QSGOpenGLTexture ::fromNativeExternalOES(mTexture, window(), boundingRect().size().toSize()); } n->setTexture(mQsgTexture); n->markDirty(QSGNode::DirtyMaterial | QSGNode::DirtyGeometry); n->setRect(boundingRect()); return n; }