Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1178


Ignore:
Timestamp:
Apr 24, 2008, 4:48:13 PM (17 years ago)
Author:
FelixSchulthess
Message:

GraphicsEngine now listening to window events…

Location:
code/branches/console/src/orxonox
Files:
2 edited

Legend:

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

    r1090 r1178  
    4040#include <OgreLogManager.h>
    4141#include <OgreTextureManager.h>
    42 #include <OgreRenderWindow.h>
    43 
     42#include "core/InputManager.h"
    4443#include "core/CoreIncludes.h"
    4544#include "core/ConfigValueIncludes.h"
     
    9089  {
    9190    COUT(4) << "*** GraphicsEngine: Destroying objects..." << std::endl;
     91    Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this);
    9292    if (this->root_)
    9393      delete this->root_;
     
    184184  {
    185185    this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
     186    Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
    186187    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
    187188    //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
     
    289290        << "*** Ogre: " << message << std::endl;
    290291  }
     292
     293    void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw){
     294        int w = rw->getWidth();
     295        int h = rw->getHeight();
     296        InputManager::getSingleton().setWindowExtents(w, h);
     297    }
     298
     299    void GraphicsEngine::windowResized(Ogre::RenderWindow *rw){
     300        int w = rw->getWidth();
     301        int h = rw->getHeight();
     302        InputManager::getSingleton().setWindowExtents(w, h);
     303    }
     304
     305    void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw){
     306        int w = rw->getWidth();
     307        int h = rw->getHeight();
     308        InputManager::getSingleton().setWindowExtents(w, h);
     309    }
    291310}
  • code/branches/console/src/orxonox/GraphicsEngine.h

    r1056 r1178  
    4242#include <OgrePrerequisites.h>
    4343#include <OgreLog.h>
    44 
     44#include <OgreRenderWindow.h>
     45#include <OgreWindowEventUtilities.h>
    4546#include "core/OrxonoxClass.h"
    4647
     
    4849namespace orxonox {
    4950
    50   /**
     51    /**
    5152    @brief Graphics engine manager class
    52   */
    53   class _OrxonoxExport GraphicsEngine : public OrxonoxClass, public Ogre::LogListener
    54   {
    55     friend class ClassIdentifier<GraphicsEngine>;
    56     public:
    57       void setConfigPath(std::string path) { this->configPath_ = path; };
    58       void setConfigValues();
    59       void setup();
    60       bool load(std::string path);
    61       void loadRessourceLocations(std::string path);
    62       Ogre::SceneManager* getSceneManager();
    63       void initialise();
    64       void destroy();
     53    */
     54    class _OrxonoxExport GraphicsEngine : public Ogre::WindowEventListener, public OrxonoxClass, public Ogre::LogListener
     55    {
     56        friend class ClassIdentifier<GraphicsEngine>;
     57        public:
     58            void setConfigPath(std::string path) { this->configPath_ = path; };
     59            void setConfigValues();
     60            void setup();
     61            bool load(std::string path);
     62            void loadRessourceLocations(std::string path);
     63            Ogre::SceneManager* getSceneManager();
     64            void initialise();
     65            void destroy();
    6566
    66       // several window properties
    67       Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
    68       size_t getWindowHandle();
    69       int getWindowWidth() const;
    70       int getWindowHeight() const;
     67            // several window properties
     68            Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
     69            size_t getWindowHandle();
     70            int getWindowWidth() const;
     71            int getWindowHeight() const;
    7172
    72       static GraphicsEngine& getSingleton();
    73       static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }
     73            static GraphicsEngine& getSingleton();
     74            static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }
    7475
    75     private:
    76       // don't mess with singletons
    77       GraphicsEngine();
    78       ~GraphicsEngine();
    79       GraphicsEngine(GraphicsEngine&) { }
     76            void windowMoved(Ogre::RenderWindow* rw);
     77            void windowResized(Ogre::RenderWindow* rw);
     78            void windowFocusChanged(Ogre::RenderWindow* rw);
    8079
    81       //! Method called by the LogListener from Ogre
    82       void messageLogged(const std::string&, Ogre::LogMessageLevel,
    83                          bool, const std::string&);
     80        private:
     81            // don't mess with singletons
     82            GraphicsEngine();
     83            ~GraphicsEngine();
     84            GraphicsEngine(GraphicsEngine&) { }
    8485
    85       Ogre::Root*         root_;        //!< Ogre's root
    86       Ogre::SceneManager* scene_;       //!< scene manager of the game
    87       Ogre::RenderWindow* renderWindow_;//!< the current render window
    88       //bool               bOverwritePath_; //!< overwrites path
    89       std::string         configPath_;  //!< path to config file
    90       std::string         dataPath_;    //!< path to data file
    91       std::string         ogreLogfile_; //!< log file name for Ogre log messages
    92       int ogreLogLevelTrivial_;         //!< Corresponding Orxonx debug level for LL_TRIVIAL
    93       int ogreLogLevelNormal_;          //!< Corresponding Orxonx debug level for LL_NORMAL
    94       int ogreLogLevelCritical_;        //!< Corresponding Orxonx debug level for LL_CRITICAL
     86            //! Method called by the LogListener from Ogre
     87            void messageLogged(const std::string&, Ogre::LogMessageLevel,
     88                             bool, const std::string&);
    9589
    96   };
    97 
     90            Ogre::Root*         root_;        //!< Ogre's root
     91            Ogre::SceneManager* scene_;       //!< scene manager of the game
     92            Ogre::RenderWindow* renderWindow_;//!< the current render window
     93            //bool               bOverwritePath_; //!< overwrites path
     94            std::string         configPath_;  //!< path to config file
     95            std::string         dataPath_;    //!< path to data file
     96            std::string         ogreLogfile_; //!< log file name for Ogre log messages
     97            int ogreLogLevelTrivial_;         //!< Corresponding Orxonx debug level for LL_TRIVIAL
     98            int ogreLogLevelNormal_;          //!< Corresponding Orxonx debug level for LL_NORMAL
     99            int ogreLogLevelCritical_;        //!< Corresponding Orxonx debug level for LL_CRITICAL
     100    };
    98101}
    99102
Note: See TracChangeset for help on using the changeset viewer.