Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 5, 2008, 9:50:26 PM (16 years ago)
Author:
rgrieder
Message:
  • getInstance is probably more suitable than getSingleton (as x3n has already done so in most of his classes) I changed it in Orxonox and GraphicsEngine. Maybe more to come.
  • Removed derivation from BaseObject in InputState (templates work well too, don't need a factory at all)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/orxonox/GraphicsEngine.cc

    r1652 r1653  
    6464namespace orxonox
    6565{
     66    SetConsoleCommand(GraphicsEngine, printScreen, true).setKeybindMode(KeybindMode::OnPress);
     67
    6668    GraphicsEngine* GraphicsEngine::singletonRef_s = 0;
    6769
     
    7274        The only instance of GraphicsEngine.
    7375    */
    74     /*static*/ GraphicsEngine& GraphicsEngine::getSingleton()
     76    /*static*/ GraphicsEngine& GraphicsEngine::getInstance()
    7577    {
    7678        assert(singletonRef_s);
     
    128130        if (this->root_)
    129131            delete this->root_;
    130         this->root_ = 0;
    131         this->levelSceneManager_ = 0;
    132         this->renderWindow_ = 0;
    133132
    134133#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
     
    154153        CCOUT(3) << "Setting up..." << std::endl;
    155154
    156         // TODO: LogManager doesn't work on linux platform. The why is yet unknown.
     155        // TODO: LogManager doesn't work on oli platform. The why is yet unknown.
    157156#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    158157        // create a new logManager
     
    193192        root_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_);
    194193
    195         if (!root_->getInstalledPlugins().size())
    196         {
    197             ThrowException(PluginsNotFound, "No Ogre plugins declared. Cannot load Ogre.");
    198         }
    199 
    200 #if 0 // Ogre 1.4.3 doesn't support setDebugOutputEnabled(.)
    201 //#if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
     194        // We don't need plugins for the dedicated..
     195        //if (!root_->getInstalledPlugins().size() > 0)
     196        //{
     197        //    ThrowException(PluginsNotFound, "No Ogre plugins declared. Cannot load Ogre.");
     198        //}
     199
     200#if 0 // Ogre 1.4.3 doesn't yet support setDebugOutputEnabled(.)
     201#if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
    202202        // tame the ogre ouput so we don't get all the mess in the console
    203203        Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog();
     
    206206        defaultLog->addListener(this);
    207207#endif
     208#endif
    208209
    209210        CCOUT(4) << "Creating Ogre Root done" << std::endl;
     
    233234            cf.load(Settings::getDataPath() + resourceFile_);
    234235        }
    235         catch (Ogre::Exception& ex)
    236         {
    237             COUT(1) << ex.getFullDescription() << std::endl;
     236        catch (...)
     237        {
     238            //COUT(1) << ex.getFullDescription() << std::endl;
    238239            COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl;
    239240            throw;
     
    300301    }
    301302
    302     bool GraphicsEngine::initialiseResources()
     303    void GraphicsEngine::initialiseResources()
    303304    {
    304305        CCOUT(4) << "Initialising resources" << std::endl;
     
    313314            }*/
    314315        }
    315         catch (Ogre::Exception& e)
    316         {
    317             CCOUT(2) << "Error: There was an Error when initialising the resources." << std::endl;
    318             CCOUT(2) << "ErrorMessage: " << e.getFullDescription() << std::endl;
    319             return false;
    320         }
    321         return true;
     316        catch (...)
     317        {
     318            CCOUT(2) << "Error: There was a serious error when initialising the resources." << std::endl;
     319            throw;
     320        }
    322321    }
    323322
     
    326325        Creates the SceneManager
    327326    */
    328     bool GraphicsEngine::createNewScene()
     327    void GraphicsEngine::createNewScene()
    329328    {
    330329        CCOUT(4) << "Creating new SceneManager..." << std::endl;
     
    332331        {
    333332            CCOUT(2) << "SceneManager already exists! Skipping." << std::endl;
    334             return false;
    335333        }
    336334        this->levelSceneManager_ = this->root_->createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
    337         CCOUT(3) << "Created SceneManager: " << levelSceneManager_ << std::endl;
    338         return true;
     335        CCOUT(3) << "Created SceneManager: " << levelSceneManager_->getName() << std::endl;
    339336    }
    340337
     
    487484    }
    488485
     486
     487    /*static*/ void GraphicsEngine::printScreen()
     488    {
     489        if (getInstance().renderWindow_)
     490        {
     491            getInstance().renderWindow_->writeContentsToTimestampedFile("shot_", ".jpg");
     492        }
     493    }
    489494}
Note: See TracChangeset for help on using the changeset viewer.