Changeset 2799 for code/branches/gui/src/orxonox/gamestates
- Timestamp:
- Mar 18, 2009, 9:15:39 PM (16 years ago)
- Location:
- code/branches/gui/src/orxonox/gamestates
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/orxonox/gamestates/GSGraphics.h
r2756 r2799 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include <OgrePrerequisites.h>34 33 #define NOMINMAX // required to stop windows.h screwing up std::min definition 35 34 #include <OgreWindowEventUtilities.h> 35 #include <OgreLog.h> 36 36 #include "core/GameState.h" 37 37 #include "core/OrxonoxClass.h" -
code/branches/gui/src/orxonox/gamestates/GSRoot.cc
r2759 r2799 33 33 #include "util/Debug.h" 34 34 #include "core/Core.h" 35 #include "core/Factory.h"36 35 #include "core/ConfigValueIncludes.h" 37 36 #include "core/CoreIncludes.h" 38 37 #include "core/ConsoleCommand.h" 39 #include "core/CommandLine.h"40 #include "core/Shell.h"41 #include "core/TclBind.h"42 #include "core/TclThreadManager.h"43 #include "core/LuaBind.h"44 38 #include "tools/Timer.h" 45 39 #include "objects/Tickable.h" 46 40 47 #ifdef ORXONOX_PLATFORM_WINDOWS48 # ifndef WIN32_LEAN_AND_MEAN49 # define WIN32_LEAN_AND_MEAN50 # endif51 # define NOMINMAX // required to stop windows.h screwing up std::min definition52 # include "windows.h"53 #endif54 55 41 namespace orxonox 56 42 { 57 SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu");58 59 43 GSRoot::GSRoot() 60 44 : RootGameState("root") … … 62 46 , bPaused_(false) 63 47 , timeFactorPauseBackup_(1.0f) 64 , tclBind_(0)65 , tclThreadManager_(0)66 , shell_(0)67 48 { 68 49 RegisterRootObject(GSRoot); … … 87 68 void GSRoot::enter() 88 69 { 89 // creates the class hierarchy for all classes with factories90 Factory::createClassHierarchy();91 92 70 // reset game speed to normal 93 71 timeFactor_ = 1.0f; … … 100 78 this->avgTickTime_ = 0.0f; 101 79 102 // Create the lua interface103 this->luaBind_ = new LuaBind();104 105 // initialise TCL106 this->tclBind_ = new TclBind(Core::getMediaPathString());107 this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());108 109 // create a shell110 this->shell_ = new Shell();111 112 // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump113 // do this after ogre has initialised. Somehow Ogre changes the settings again (not through114 // the timer though).115 int limitToCPU = CommandLine::getValue("limitToCPU");116 if (limitToCPU > 0)117 setThreadAffinity((unsigned int)(limitToCPU - 1));118 119 80 { 120 81 // add console commands … … 156 117 delete this->ccSelectGameState_; 157 118 158 delete this->shell_;159 delete this->tclThreadManager_;160 delete this->tclBind_;161 162 delete this->luaBind_;163 164 119 if (this->ccSetTimeFactor_) 165 120 { … … 179 134 uint64_t timeBeforeTick = time.getRealMicroseconds(); 180 135 181 TclThreadManager::getInstance().tick(time.getDeltaTime());136 Core::getInstance().tick(time); 182 137 183 138 for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it) … … 235 190 236 191 /** 237 @note238 The code of this function has been copied and adjusted from OGRE, an open source graphics engine.239 (Object-oriented Graphics Rendering Engine)240 For the latest info, see http://www.ogre3d.org/241 242 Copyright (c) 2000-2008 Torus Knot Software Ltd243 244 OGRE is licensed under the LGPL. For more info, see OGRE license.245 */246 void GSRoot::setThreadAffinity(unsigned int limitToCPU)247 {248 #ifdef ORXONOX_PLATFORM_WINDOWS249 // Get the current process core mask250 DWORD procMask;251 DWORD sysMask;252 # if _MSC_VER >= 1400 && defined (_M_X64)253 GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);254 # else255 GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);256 # endif257 258 // If procMask is 0, consider there is only one core available259 // (using 0 as procMask will cause an infinite loop below)260 if (procMask == 0)261 procMask = 1;262 263 // if the core specified with limitToCPU is not available, take the lowest one264 if (!(procMask & (1 << limitToCPU)))265 limitToCPU = 0;266 267 // Find the lowest core that this process uses and limitToCPU suggests268 DWORD threadMask = 1;269 while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))270 threadMask <<= 1;271 272 // Set affinity to the first core273 SetThreadAffinityMask(GetCurrentThread(), threadMask);274 #endif275 }276 277 /**278 192 @brief 279 193 Changes the speed of Orxonox -
code/branches/gui/src/orxonox/gamestates/GSRoot.h
r2710 r2799 33 33 34 34 #include <list> 35 #include <OgreLog.h>36 35 #include "core/RootGameState.h" 37 36 #include "core/OrxonoxClass.h" … … 76 75 77 76 void setConfigValues(); 78 void setThreadAffinity(unsigned int limitToCPU);79 77 80 78 float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal. 81 79 bool bPaused_; 82 80 float timeFactorPauseBackup_; 83 TclBind* tclBind_;84 TclThreadManager* tclThreadManager_;85 Shell* shell_;86 LuaBind* luaBind_;87 81 88 82 // variables for time statistics
Note: See TracChangeset
for help on using the changeset viewer.