Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 3, 2007, 11:06:43 PM (16 years ago)
Author:
rgrieder
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/main_reto_vs05/src/ogre_control.cc

    r157 r159  
    2626 */
    2727
     28/**
     29* Ogre control class.
     30* This is merely a convenient way to handle Ogre. It only holds the Root
     31* object and the render Window. These are the objects, that are independant
     32* of the game state (playing, menu browsing, loading, etc.).
     33* This class could easily be merged into the Orxnox class.
     34*/
     35
     36
    2837#include "ogre_control.h"
    2938
    3039
     40/**
     41* Provide support for mac users.
     42*/
    3143#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    3244// This function will locate the path to our application on OS X,
     
    5668
    5769
    58 OgreControl::OgreControl()
    59 {
    60         mRoot = 0;
     70/**
     71* Constructor that determines the resource path platform dependant.
     72*/
     73OgreControl::OgreControl() : root_(0)
     74{
    6175        // Provide a nice cross platform solution for locating the configuration
    6276        // files. On windows files are searched for in the current working
     
    6478  // function macBundlePath does this for us.
    6579#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    66         mResourcePath = macBundlePath() + "/Contents/Resources/";
     80        resourcePath_ = macBundlePath() + "/Contents/Resources/";
    6781#else
    68         mResourcePath = "";
    69 #endif
    70 }
    71 
    72 
    73 // standard destructor
     82        resourcePath_ = "";
     83#endif
     84}
     85
     86
     87/**
     88* Standard Destructor.
     89*/
    7490OgreControl::~OgreControl()
    7591{
    76         if (mRoot)
    77                 delete mRoot;
    78 }
    79 
    80 
    81 /**------------- SETTING UP OGRE --------------**/
    82 
     92        if (root_)
     93                delete root_;
     94}
     95
     96
     97/* Sets up Ogre.
     98* First, the Root object is being created, then the resources are defined
     99* (not loaded!). And last but not least, the render settings (like resolution
     100* or AA level) are prompted to the user.
     101*/
    83102bool OgreControl::initialise(void)
    84103{
     
    86105        // only use plugins.cfg if not static
    87106#ifndef OGRE_STATIC_LIB
    88         pluginsPath = mResourcePath + "plugins.cfg";
    89 #endif
    90 
    91         mRoot = new Root(pluginsPath,
    92                 mResourcePath + "ogre.cfg", mResourcePath + "Ogre.log");
     107        pluginsPath = resourcePath_ + "plugins.cfg";
     108#endif
     109
     110        root_ = new Root(pluginsPath,
     111                resourcePath_ + "ogre.cfg", resourcePath_ + "Ogre.log");
    93112
    94113        setupResources();
     
    101120
    102121
    103 // Method which will define the source of resources
    104 // (other than current folder)
     122/**
     123* Defines the source of the resources.
     124*/
    105125void OgreControl::setupResources(void)
    106126{
    107127        // Load resource paths from config file
    108128        ConfigFile cf;
    109         cf.load(mResourcePath + "resources.cfg");
     129        cf.load(resourcePath_ + "resources.cfg");
    110130
    111131        // Go through all sections & settings in the file
     
    137157
    138158
     159/**
     160* Prompts a setting window for the render engine if that has not already
     161* been done.
     162* The method also calls the root initialiser in order to get a render window.
     163*/
    139164bool OgreControl::configure(void)
    140165{
     
    142167        // You can skip this and use root.restoreConfig() to load configuration
    143168        // settings if you were sure there are valid ones saved in ogre.cfg
    144         if(!mRoot->restoreConfig() && !mRoot->showConfigDialog())
     169        if(!root_->restoreConfig() && !root_->showConfigDialog())
    145170                return false;
    146171
     
    148173        // Here we choose to let the system create a default
    149174  // rendering window by passing 'true'
    150         mWindow = mRoot->initialise(true);
    151         mRoot->saveConfig();
     175        root_->saveConfig();
     176        window_ = root_->initialise(true);
    152177        return true;
    153178}
    154179
    155180
     181/**
     182* Returns the root object.
     183* @return Root object.
     184*/
    156185Root* OgreControl::getRoot(void)
    157186{
    158         return mRoot;
    159 }
    160 
    161 
     187        return root_;
     188}
     189
     190
     191/**
     192* Returns the render window.
     193* @return Render window.
     194*/
    162195RenderWindow* OgreControl::getRenderWindow(void)
    163196{
    164         return mWindow;
    165 }
    166 
    167 
     197        return window_;
     198}
     199
     200
     201/**
     202* Returns the resource path.
     203* @return Resource path.
     204*/
    168205Ogre::String OgreControl::getResourcePath(void)
    169206{
    170         return mResourcePath;
    171 }
     207        return resourcePath_;
     208}
Note: See TracChangeset for help on using the changeset viewer.