Retrive QML's QOpenGL context
-
Hi,
I want to create a secondary OpenGL context shared with QML's
QOpenGLContext
to do background texture/mesh loading then rendering these assets in aQQuickFramebufferObject
with QML's OpenGL context.Problem is I can't find a "clean" way to retrieve QML's OpenGL context.
The only way I found right now is to have a
BackgroundLoader
class inherinting fromQQuickPaintedItem
, use it somewhere in QML, then wait for apaint
call to retrieve the bound context usingQOpenGLContext::currentContext()
. After retrieving it, I can then create my secondary context. This feels like a hack and not the correct way to handle this (it does not work if my item is not rendered (size of 0)).Is there a way to retrieve QML's OpenGL context from C++ easily ? (I have access to the
QQmlEngine
and to aQQuickItem
that I use to manage my 3D views). I don't need it to be bound. Just get a pointer to it to share it with my secondary context.Thanks
-
Hi,
I want to create a secondary OpenGL context shared with QML's
QOpenGLContext
to do background texture/mesh loading then rendering these assets in aQQuickFramebufferObject
with QML's OpenGL context.Problem is I can't find a "clean" way to retrieve QML's OpenGL context.
The only way I found right now is to have a
BackgroundLoader
class inherinting fromQQuickPaintedItem
, use it somewhere in QML, then wait for apaint
call to retrieve the bound context usingQOpenGLContext::currentContext()
. After retrieving it, I can then create my secondary context. This feels like a hack and not the correct way to handle this (it does not work if my item is not rendered (size of 0)).Is there a way to retrieve QML's OpenGL context from C++ easily ? (I have access to the
QQmlEngine
and to aQQuickItem
that I use to manage my 3D views). I don't need it to be bound. Just get a pointer to it to share it with my secondary context.Thanks