Unsolved QopenglWidget share context among thread
-
This post is deleted! -
The thread is stopped (and deleted in your case since your signals/slot connection) as soon as run() finishes which is pretty fast in your case...
The signal resultReady is also not emitted anywhere -
@Christian-Ehrlicher
thank you for the reply, the signal is received correvtly in the main thread. but when i cretae the opengltexture the context is not valid -
The signal resultReady() is not sent in your example so I guess it's incomplete.
-
@Christian-Ehrlicher you are right copy/paste error but i sent the signal right the unmap of the frame.
But it gives error when create the opengltexture because the context is not valid -
And where do you use the QOpenGLContext created in updateVideoFrame()? Did you check that the generated QImage is valid?
-
@Christian-Ehrlicher
the image is correct i also save it on hdd and it is fine.
in the updatevideoframe i just create the context share it and move the thread. Maybe do i need something else? -
I've no more idea but I think you don't need a context at all. From the QOpenGLTexture ctor description:
This does create the underlying OpenGL texture object. Therefore, construction using this constructor does require a valid current OpenGL context.
Maybe also check for QOpenGLTexture::isCreated() in thread and main thread.
And I wonder if you need a thread for this small calculation at all - since not much is done the thread overhead looks much bigger than the benefit. -
@Christian-Ehrlicher i know that the qopenglwidget creates the underlying context and it is shared among all the others widget and it works because i used it.
but for documentation to use context in a different thread i have to use share context but... -
I use
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
before I create my QApplication in main to make sure all contexts are sharing by default. I had some trouble getting sharing to work after porting some code from QGLWidget to QopenGLWidget a few years back, and that was the bit that got everything working for me.