bool application::frameRenderingQueued (Ogre::FrameEvent const& e)
{
    if (wnd->isClosed()) return false;
    if (shutdown)        return false;

    kbd   -> capture();
    mouse -> capture();

    tray_mgr->frameRenderingQueued(e);

    if (!tray_mgr->isDialogVisible())
        cameraman->frameRenderingQueued(e);

    return true;
}
bool application::keyPressed (OIS::KeyEvent const& arg)
{
    if (tray_mgr->isDialogVisible()) return true;

    if (arg.key == OIS::KC_F)
    {
        tray_mgr->toggleAdvancedFrameStats();
    }
    else if (arg.key == OIS::KC_R)
    {
        Ogre::PolygonMode pm;

        switch (cam->getPolygonMode())
        {
        case Ogre::PM_SOLID:
            pm = Ogre::PM_WIREFRAME;
            break;

        case Ogre::PM_WIREFRAME:
            pm = Ogre::PM_POINTS;
            break;

        default:
            pm = Ogre::PM_SOLID;
            break;
        }

        cam->setPolygonMode(pm);
    }
    else if (arg.key == OIS::KC_F5)
    {
        Ogre::TextureManager::getSingleton().reloadAll();
    }
    else if (arg.key == OIS::KC_SYSRQ)
    {
        wnd->writeContentsToTimestampedFile ("screenshot", ".png");
    }
    else if (arg.key == OIS::KC_ESCAPE)
    {
        shutdown = true;
    }

    cameraman->injectKeyDown(arg);
    return true;
}