To use the class "GLDepthBuffer", you will have to manually include (and link) the OpenGL RenderSystem into your application (since that class is part of that Ogre plugin):
However, Ogre currently does not provide a direct way to retrieve the depth buffer. The following code will help you to get the GLDepthBuffer instance:
Ogre::DepthBuffer* pDepthBuffer = OgreFramework::getSingletonPtr()->m_pViewport->getTarget()->getDepthBuffer();
if(OgreFramework::getSingletonPtr()->m_pRoot->getRenderSystem()->getName().find("OpenGL") != Ogre::String::npos)
Ogre::GLDepthBuffer* pGlDepthBuffer = static_cast<Ogre::GLDepthBuffer*>(pDepthBuffer);
Ogre::GLRenderBuffer* pRenderBuffer = pGlDepthBuffer->getDepthBuffer();
Unfortunately, the last line will not yield the expected result, since that will only return a null pointer as described in the API.
Bottom-line: You will have to find a way to access the depth buffer in OpenGL via the context (Ogre::GLContext and its subclasses for various platforms) or the FBOs. As a starting point, search the following method in the Ogre code base (part of multiple classes):
getCustomAttribute( const String& name, void* pData )
Alternatively you can also retrieve the context by adding the following lines below the previous code snippet (on Windows; other platforms have similar ways):
Ogre::GLContext* pGLContext = pGlDepthBuffer->getGLContext();
Ogre::Win32Context* pWinContext = static_cast<Ogre::Win32Context*>(pGLContext);
If you found a way, please let us know either on the forums or even better, create a pull-request for our repository on BitBucket and we might merge it in.