Hey, I've uploaded the files. A short disclaimer first:
You'll find some members and classes that are pretty much unrelated to making NoesisGUI work with Ogre OpenGL. There is one mouse cursor class (that is using the Ogre Overlay system, we will replace that using Noesis as well later), some classes that bind functions to Lua scripts. You can basically ignore all those. There is also no binding from OIS keyboard keys to Noesis key codes.
The most important functions to you are probably the store and restoreCurrentRenderStates.
I had to comment some of the GL functions there as they were causing OpenGL errors during runtime (it was working, but the GL errors were logging away).
Here are the files:
Header
Source
You will also need the OgreNsGuiStream and OgreNsGuiFileSystem files/classes from the official Ogre Noesis bindings (you can find them on the repo).
And here is how we use those:
Initialization (we use an extra SceneManager for GUI, but maybe using visibility flags would be faster) and Cleanup:
// setup gui scene manager
// the extra scene manager is there to prevent anything being rendered on the render target other than the gui
_guiTexture = TextureManager::getSingleton().createManual("GuiTexture", "RenderTextureGroup", TEX_TYPE_2D, _window->getWidth(), _window->getHeight(), 0, PF_B8G8R8A8, TU_RENDERTARGET);
_guiRenderTarget = _guiTexture->getBuffer()->getRenderTarget();
_guiRenderTarget->setAutoUpdated(true);
_guiSceneMgr = _root->createSceneManager("OctreeSceneManager", "GuiSceneManager");
// Create the camera
_guiCamera = _guiSceneMgr->createCamera("GuiCam");
_guiCamera->setNearClipDistance(1);
_guiCamera->setFarClipDistance(3000);
// Create one viewport, entire window
_guiViewport = _guiRenderTarget->addViewport(_guiCamera);
_guiViewport->setBackgroundColour(Ogre::ColourValue(0,0,0,0));
// Alter the camera aspect ratio to match the viewport
_guiCamera->setAspectRatio(
Ogre::Real(_guiViewport->getActualWidth()) / Ogre::Real(_guiViewport->getActualHeight()));
_guiManager = new NoesisManager();
if (!_guiManager->setup(_guiSceneMgr, _root, _memoryLog, _inputManager->getMouse(),
_window->getWidth(), _window->getHeight()))
{
CONSOLE_LOG("Failed to setup gui!");
return false;
}
// Cleanup code
_guiManager->shutdown();
delete _guiManager;
_guiManager = 0;
And this is done during the render loop:
// Take time
lastProgTime = progTime;
progTime = ((float)_root->getTimer()->getMilliseconds()) / 1000.0f;
_timeSinceLastFrame = progTime - lastProgTime;
// Render a frame
_guiManager->doPreSceneStep((double)_timeSinceLastFrame);
_root->renderOneFrame();