System Information
- Ogre Version: 14.3 and 14.5
- Operating System / Platform: Linux (Wayland)
- RenderSystem: OpenGL ES 2
Detailled description
When the OpenGL ES 2 rendersystem creates a depth buffer, the current OpenGL context is used. When using multiple render windows, this could be the context from the second window. When choosing which depth buffer gets attached to an FBO; regarding the OGL context, any depth buffer can be chosen.
We encountered a problem where the (opaque) objects in a scene suddenly get rendered in the wrong order. This occurs when the second window gets closed and gets destroyed through Ogre::Root::getSingletonPtr()->destroyRenderTarget(...). What probably happens is that along with the second window context, the corresponding depth buffers get destroyed as well, while these are attached to FBO's shown on the main window.
Our current workaround is to set the main window's context active any time an FBO is made, which ensures the main window's context is active during depth buffer creation. Setting the main window's context active is done through Ogre::Root::getSingletonPtr()->getRenderSystem()->_setViewport(<main_window_vp>). After creating the FBO, we restore the previous viewport through another _setViewport call.
But perhaps a better solution is to let the GLES2RenderSystem::_createDepthBufferFor function always use the main context before actually creating the depth buffer? Or maybe there's a more elegant way to solve this in our own non-Ogre code?
System Information
Detailled description
When the OpenGL ES 2 rendersystem creates a depth buffer, the current OpenGL context is used. When using multiple render windows, this could be the context from the second window. When choosing which depth buffer gets attached to an FBO; regarding the OGL context, any depth buffer can be chosen.
We encountered a problem where the (opaque) objects in a scene suddenly get rendered in the wrong order. This occurs when the second window gets closed and gets destroyed through
Ogre::Root::getSingletonPtr()->destroyRenderTarget(...). What probably happens is that along with the second window context, the corresponding depth buffers get destroyed as well, while these are attached to FBO's shown on the main window.Our current workaround is to set the main window's context active any time an FBO is made, which ensures the main window's context is active during depth buffer creation. Setting the main window's context active is done through
Ogre::Root::getSingletonPtr()->getRenderSystem()->_setViewport(<main_window_vp>). After creating the FBO, we restore the previous viewport through another_setViewportcall.But perhaps a better solution is to let the
GLES2RenderSystem::_createDepthBufferForfunction always use the main context before actually creating the depth buffer? Or maybe there's a more elegant way to solve this in our own non-Ogre code?