Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/GraphicsEngine.cc @ 1832

Last change on this file since 1832 was 1755, checked in by rgrieder, 16 years ago

merged gui back to trunk.
update the media repository!

  • Property svn:eol-style set to native
File size: 3.7 KB
RevLine 
[612]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
[1293]3 *                    > www.orxonox.net <
[612]4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
[1349]11 *   of the License, or (at your option) any later version.
12 *
[612]13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
[1535]23 *      Reto Grieder
[1755]24 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
[612]25 *   Co-authors:
[1755]26 *      Felix Schulthess
[612]27 *
28 */
[1035]29
[1755]30/**
31@file
32@brief
33    Implementation of an partial interface to Ogre.
34*/
[612]35
[1021]36#include "OrxonoxStableHeaders.h"
[1039]37#include "GraphicsEngine.h"
[612]38
[1755]39#include <OgreRenderWindow.h>
[1538]40
[1293]41#include "core/CoreIncludes.h"
42#include "core/ConfigValueIncludes.h"
[1747]43#include "util/Debug.h"
[1535]44
[1563]45#include "tools/ParticleInterface.h"
[1032]46
[1625]47namespace orxonox
48{
[1755]49    //SetConsoleCommand(GraphicsEngine, printScreen, true).setKeybindMode(KeybindMode::OnPress);
[1032]50
[1755]51    GraphicsEngine* GraphicsEngine::singletonRef_s = 0;
[1293]52
[1755]53    /**
54    @brief
55        Returns the singleton instance.
56    @return
57        The only instance of GraphicsEngine.
58    */
59    /*static*/ GraphicsEngine& GraphicsEngine::getInstance()
[1024]60    {
[1755]61        assert(singletonRef_s);
62        return *singletonRef_s;
[1024]63    }
[612]64
[1755]65    /**
66    @brief
67        Non-initialising constructor.
68    */
69    GraphicsEngine::GraphicsEngine()
70        : root_(0)
71        , renderWindow_(0)
72        , levelSceneManager_(0)
73        , viewport_(0)
[1535]74    {
[1755]75        RegisterObject(GraphicsEngine);
[1502]76
[1755]77        assert(singletonRef_s == 0);
78        singletonRef_s = this;
[1535]79
[1755]80        this->detailLevelParticle_ = 0;
[1535]81
[1755]82        this->setConfigValues();
83        CCOUT(4) << "Constructed" << std::endl;
[1535]84    }
85
[1755]86    void GraphicsEngine::setConfigValues()
[1535]87    {
[1755]88        SetConfigValue(detailLevelParticle_, 2).description("O: off, 1: low, 2: normal, 3: high").callback(this, &GraphicsEngine::detailLevelParticleChanged);
[1535]89    }
[612]90
[1755]91    void GraphicsEngine::detailLevelParticleChanged()
[612]92    {
[1755]93        for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
94            it->detailLevelChanged(this->detailLevelParticle_);
[612]95    }
96
[1755]97    /**
98    @brief
99        Destroys all the Ogre related objects
100    */
101    GraphicsEngine::~GraphicsEngine()
[1538]102    {
[1755]103        singletonRef_s = 0;
[1538]104    }
105
[1755]106    /**
107    @brief
108        Get the width of the render window
109    @return
110        The width of the render window
111    */
112    int GraphicsEngine::getWindowWidth() const
[1535]113    {
[1755]114        if (this->renderWindow_)
115            return this->renderWindow_->getWidth();
116        else
117            return 0;
[1535]118    }
119
[1755]120    /**
121    @brief
122        Get the height of the render window
123    @return
124        The height of the render window
125    */
126    int GraphicsEngine::getWindowHeight() const
[1293]127    {
[1755]128        if (this->renderWindow_)
129            return this->renderWindow_->getHeight();
130        else
131            return 0;
[1293]132    }
133
[1755]134    /**
135    @brief
136        Returns the window aspect ratio height/width.
137    @return
138        The window aspect ratio
139    */
140    float GraphicsEngine::getWindowAspectRatio() const
[1293]141    {
[1755]142        if (this->renderWindow_)
143            return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();
144        else
145            return 1.0f;
[1293]146    }
[612]147}
Note: See TracBrowser for help on using the repository browser.