Changeset 1674 for code/branches/gui/src/orxonox/gamestates/GSRoot.cc
- Timestamp:
- Aug 28, 2008, 8:30:25 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/orxonox/gamestates/GSRoot.cc
r1672 r1674 30 30 #include "GSRoot.h" 31 31 32 #include "util/SubString.h"32 //#include "util/SubString.h" 33 33 #include "core/Factory.h" 34 34 #include "core/ConfigFileManager.h" … … 39 39 #include "core/Exception.h" 40 40 #include "core/TclBind.h" 41 #include "core/Core.h"42 #include "core/CommandLine.h"43 41 #include "core/TclThreadManager.h" 44 42 #include "GraphicsEngine.h" 45 43 #include "Settings.h" 44 45 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 46 # ifndef WIN32_LEAN_AND_MEAN 47 # define WIN32_LEAN_AND_MEAN 48 # endif 49 # include "windows.h" 50 51 //Get around Windows hackery 52 # ifdef max 53 # undef max 54 # endif 55 # ifdef min 56 # undef min 57 # endif 58 #endif 46 59 47 60 namespace orxonox … … 119 132 graphicsEngine_->setup(); // creates ogre root and other essentials 120 133 134 // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump 135 // do this after ogre has initialised. Somehow Ogre changes the settings again (not through 136 // the timer though). 137 setThreadAffinity(); 138 121 139 // add console commands 122 140 FunctorMember<GSRoot>* functor1 = createFunctor(&GSRoot::exitGame); … … 138 156 } 139 157 140 void GSRoot::ticked(float dt, uint64_t time) 141 { 142 TclThreadManager::getInstance().tick(dt); 143 144 this->tickChild(dt, time); 158 void GSRoot::ticked(const Clock& time) 159 { 160 TclThreadManager::getInstance().tick(time.getDeltaTime()); 161 162 this->tickChild(time); 163 } 164 165 /** 166 @note 167 The code of this function has been copied from OGRE, an open source graphics engine. 168 (Object-oriented Graphics Rendering Engine) 169 For the latest info, see http://www.ogre3d.org/ 170 171 Copyright (c) 2000-2008 Torus Knot Software Ltd 172 173 OGRE is licensed under the LGPL. For more info, see ogre license info. 174 */ 175 void GSRoot::setThreadAffinity() 176 { 177 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 178 // Get the current process core mask 179 DWORD procMask; 180 DWORD sysMask; 181 #if _MSC_VER >= 1400 && defined (_M_X64) 182 GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask); 183 #else 184 GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask); 185 #endif 186 187 // If procMask is 0, consider there is only one core available 188 // (using 0 as procMask will cause an infinite loop below) 189 if (procMask == 0) 190 procMask = 1; 191 192 // Find the lowest core that this process uses 193 DWORD threadMask = 1; 194 while ((threadMask & procMask) == 0) 195 threadMask <<= 1; 196 197 // Set affinity to the first core 198 SetThreadAffinityMask(GetCurrentThread(), threadMask); 199 #endif 145 200 } 146 201 }
Note: See TracChangeset
for help on using the changeset viewer.