How does QVideoFilterRunnable and OpenGL Context works together?
I'm trying to program an augmented reality (AR) app with C++, Qt, QML, OpenCV and OpenGL on Android.
Principle workflow:
QVideoFilterRunnable::run(...)
Code example to manipulate the videoframe texture:
QVideoFrame FilterRunnable::run(QVideoFrame* input,
const QVideoSurfaceFormat &sFormat,
RunFlags flags)
{
if(sFormat.handleType() == QAbstractVideoBuffer::GLTextureHandle)
{
QOpenGLContext* c = QOpenGLContext::currentContext();
QOpenGLFunctions* f = c->functions();
GLuint textID = input->handle().toInt();
f->glBindTexture(GL_TEXTURE_2D,textID);
float pixels[] = {
0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
};
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
f->glTexImage2D(GL_TEXTURE_2D,
0, GL_RGB,
2, 2, 0,
GL_RGB, GL_FLOAT, pixels);
}
}
With glTexImage2D()
the screen becomes black whithout any error.
The problem is that I did't find any infos how FilterRunnable::run()
handles the OpenGL context in the background. I don't know how using glDrawArrays()
, glViewport()
without the standard functions initializeGL()
, resizeGL()
, paintGL()
.
For example, I want to combine the videoframe (mapped on a background polygon) together with arbitrary OpenGL objects in front of it.
Where I can get info regarding this topic or what is the best way?
链接地址: http://www.djcxy.com/p/63886.html