fix(viz): orientation marker and spheres crop box disappear after a second display in any activity
Description
Orientation marker and spheres crop box disappear after a second display in any activity.
This is actually a deadly symptom of a very bad issue, when we reworked the 3D widget to support overlays.
What I tried to achieve: I wanted to be able to overlay Qt widgets over many 3D Ogre widgets.
What I did:
The "recommended" QWindow
way does not allow, in my experience, to achieve this, with transparency. Thus, I derived from QOpenGLWidget
, so that I get a Qt OpenGL context and the render target associated with the painting area. I struggled with Ogre::RenderWindow because I could not prevent it from writing in the back buffer in the end. Instead, I created render textures for each of the layer (viewport) composing what was a render window. Since a RenderTexture, in the end (with compositors, etc...) always render in its own FBO, I hacked a post blit pass with a quad and a manual render, in order to render in the Qt FBO . This works successfully in most cases.
Why it does not work:
I had a wrong understanding of Qt::AA_ShareOpenGLContexts
. I understood I had only one GL context, but no, I got one GL context for each widget. All contexts are shared, so yes most things that can be shared work. But VAO can't be shared that's why it does not work. Since I hacked a bit the whole stuff by not using Ogre::RenderWindow, Ogre is never aware of the OpenGL context change. Thus, the code supposed to recreate the VAO if the context changes is not triggered. I had other symptoms about that, for instance when I reuse a mesh resource loaded by the Ogre::MeshManager
Steps to reproduce
- Launch ExActivity
- Complete the workflow and switch between Negato and Volume Rendering activities. Observe sphere widgets disappear the second time.
Technical specifications
I finally found a fix that allows informing Ogre about the current GL Context.
Test plan
Describe how you will verify that the implementation fulfils the specifications