[SOLVED] Order of execution of QOffscreenSurface and QOpenGLContex.
-
I want to draw a image in the QOpenGLFramebufferObject and I use QOffscreenSurface for rendering in another thread without creating a QWindow.
I wrote this part of code for initialize OpenGL context and on Windows all works fine.
@
m_surface.create();
m_context = new QOpenGLContext(this);
m_context->setFormat(m_surface.requestedFormat());
m_context->create();
m_context->makeCurrent(&m_surface);
@But on my work Linux PC I have segfault in 2-nd row. And if I swap first two rows and run on Linux all works fine again.
And question is "Why?". It's a bug or maybe I doing something wrong? I didn't find any information about order of execution for surface and context in the documentation.
PS I don't run swapped version on Windows. And don't know whether it work.
-
Not sure about the crash, but be aware that creating (as in create()) a QOffscreenSurface outside the gui thread is wrong, at least on Windows. This is because on Windows the QOffscreenSuface is nothing but a hidden QWindow and a regular window surface. Creating QWindows outside the gui thread will lead to issues sooner or later so it must be avoided. In fact Qt 5.2.1 and newer will show a warning in this case. On Linux there is no such limitation, though, since there QOffscreenSurface is backed by a GLX or EGL pbuffer surface.