Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 10, 2008, 5:03:34 PM (16 years ago)
Author:
bknecht
Message:

merged back that script-branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/GraphicsEngine.cc

    r790 r1021  
    3333
    3434#include <OgreRoot.h>
     35#include <OgreException.h>
    3536#include <OgreConfigFile.h>
    3637#include <OgreTextureManager.h>
     38#include <OgreRenderWindow.h>
    3739
     40#include "core/CoreIncludes.h"
    3841#include "core/Debug.h"
    3942#include "GraphicsEngine.h"
     
    4649  GraphicsEngine::GraphicsEngine()
    4750  {
     51    RegisterObject(GraphicsEngine);
     52    //this->bOverwritePath_ = false;
     53    this->setConfigValues();
    4854    // set to standard values
    4955    this->configPath_ = "";
    50     this->dataPath_ = "";
    51     scene_ = NULL;
     56    this->root_ = 0;
     57    this->scene_ = 0;
     58    this->renderWindow_ = 0;
    5259  }
    5360
     
    5562  GraphicsEngine::~GraphicsEngine()
    5663  {
     64    if (!this->root_)
     65      delete this->root_;
     66  }
     67
     68  void GraphicsEngine::setConfigValues()
     69  {
     70    SetConfigValue(dataPath_, dataPath_).description("relative path to media data");
     71
    5772  }
    5873
     
    6681    root_ = new Root(NULL, configPath_ + "ogre.cfg", configPath_ + "Ogre.log");
    6782#endif*/
    68 #if defined(_DEBUG) && defined(WIN32)
     83#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && defined(_DEBUG)
    6984    std::string plugin_filename = "plugins_d.cfg";
    7085#else
     
    87102  }
    88103
    89   bool GraphicsEngine::load()
     104  bool GraphicsEngine::load(std::string dataPath)
    90105  {
     106    // temporary overwrite of dataPath, change ini file for permanent change
     107    if( dataPath != "" )
     108      dataPath_ = dataPath;
    91109    loadRessourceLocations(this->dataPath_);
    92110    if (!root_->restoreConfig() && !root_->showConfigDialog())
     
    95113  }
    96114
    97   void GraphicsEngine::startRender()
     115  void GraphicsEngine::initialise()
    98116  {
    99     root_->initialise(true, "OrxonoxV2");
     117    this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
    100118    TextureManager::getSingleton().setDefaultNumMipmaps(5);
     119    //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
    101120    ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    102121  }
     
    131150  }
    132151
     152  /**
     153    Returns the window handle of the render window.
     154    At least the InputHandler uses this to create the OIS::InputManager
     155    @return The window handle of the render window
     156  */
     157  size_t GraphicsEngine::getWindowHandle()
     158  {
     159    if (this->renderWindow_)
     160    {
     161      Ogre::RenderWindow *renderWindow = this->root_->getAutoCreatedWindow();
     162      size_t windowHnd = 0;
     163      renderWindow->getCustomAttribute("WINDOW", &windowHnd);
     164      return windowHnd;
     165    }
     166    else
     167      return 0;
     168  }
     169
     170  /**
     171    Get the width of the current render window
     172    @return The width of the current render window
     173  */
     174  int GraphicsEngine::getWindowWidth() const
     175  {
     176    if (this->renderWindow_)
     177    {
     178      return this->renderWindow_->getWidth();
     179    }
     180    else
     181      return 0;
     182  }
     183
     184  /**
     185    Get the height of the current render window
     186    @return The height of the current render window
     187  */
     188  int GraphicsEngine::getWindowHeight() const
     189  {
     190    if (this->renderWindow_)
     191    {
     192      return this->renderWindow_->getHeight();
     193    }
     194    else
     195      return 0;
     196  }
    133197
    134198}
Note: See TracChangeset for help on using the changeset viewer.